Skip to content

Set SqlDscServerPermission

dscbot edited this page Mar 3, 2024 · 2 revisions

Set-SqlDscServerPermission

SYNOPSIS

Set permission for a login.

SYNTAX

Set-SqlDscServerPermission [-ServerObject] <Server> [-Name] <String> [-State] <String>
 [-Permission] <ServerPermissionSet> [-WithGrant] [-Force] [-WhatIf]
 [-Confirm] [<CommonParameters>]

DESCRIPTION

This command sets the permissions for a existing login on a SQL Server Database Engine instance.

EXAMPLES

EXAMPLE 1

$serverInstance = Connect-SqlDscDatabaseEngine

$setPermission = [Microsoft.SqlServer.Management.Smo.ServerPermissionSet] @{ Connect = $true Update = $true }

Set-SqlDscServerPermission -ServerObject $serverInstance -Name 'MyPrincipal' -State 'Grant' -Permission $setPermission

Sets the permissions for the principal 'MyPrincipal'.

PARAMETERS

-Force

Specifies that the permissions should be set without any confirmation.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Name

Specifies the name of the principal for which the permissions are set.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Permission

Specifies the permissions.

Type: ServerPermissionSet
Parameter Sets: (All)
Aliases:

Required: True
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ServerObject

Specifies current server connection object.

Type: Server
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-State

Specifies the state of the permission.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-WithGrant

Specifies that the principal should also be granted the right to grant other principals the same permission. This parameter is only valid when parameter State is set to Grant or Revoke. When the parameter State is set to Revoke the right to grant will also be revoked, and the revocation will cascade.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
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

None.

NOTES

If specifying -ErrorAction 'SilentlyContinue' then the command will silently ignore if the principal is not present. If specifying -ErrorAction 'Stop' the command will throw an error if the principal is missing.

RELATED LINKS

Home

General

Commands

Clone this wiki locally