New-SQLReadUser
SYNOPSIS
Create a new SQL Read-Only user in a specified database.
SYNTAX
New-SQLReadUser [-DBName] <String> [-SQLServer] <String> [[-PwdstateListID] <String>] [[-Username] <String>]
[<CommonParameters>]
DESCRIPTION
This function creates a new SQL Read-Only user in a specified database. It generates a secure password for the user, assigns read-only permissions, and optionally stores the credentials in Passwordstate.
EXAMPLES
EXAMPLE 1
Creates a new SQL Read-Only user in the "TestDB" database on "SQLInstance1" and stores the credentials in Passwordstate.
EXAMPLE 2
Creates a new SQL Read-Only user in the "ProdDB" database on "SQLInstance2" and stores the credentials in Passwordstate list ID 123.
EXAMPLE 3
Creates a new SQL Read-Only user named "CustomReader" in the "FinanceDB" database on "SQLInstance3".
PARAMETERS
-DBName
The name of the database where the SQL Read-Only user will be created.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-SQLServer
The name of the SQL Server instance where the database resides.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-PwdstateListID
The Passwordstate list ID where the generated credentials will be stored. Defaults to 733.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: 733
Accept pipeline input: False
Accept wildcard characters: False
-Username
An alternative SQL username. If not provided, a default username will be generated based on the database name.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: Default
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
INPUTS
OUTPUTS
NOTES
YYYY-MM-DD - Naam - Wat gewijzigd 2018-02-08 - MM - Initieel script - Aanpassing zodat dit met SQLServer-cmdlets werkt 2020-04-17 - JT - Owner wordt op sa ingesteld 2020-08-18 - JT - ADR op SQL2019 DB's ingeschakeld