Remove‑SqlDscLogin - dsccommunity/SqlServerDsc GitHub Wiki
Removes a SQL Server login.
Remove-SqlDscLogin -ServerObject <Server> -Name <String> [-KillActiveSessions] [-Force] [-Refresh]
[-WhatIf] [-Confirm] [<CommonParameters>]
Remove-SqlDscLogin -LoginObject <Login> [-KillActiveSessions] [-Force]
[-WhatIf] [-Confirm] [<CommonParameters>]
This command removes a SQL Server login from a SQL Server Database Engine instance.
$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$loginObject = $serverObject | Get-SqlDscLogin -Name 'MyLogin'
$loginObject | Remove-SqlDscLogin
Removes the login named MyLogin.
$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$serverObject | Remove-SqlDscLogin -Name 'MyLogin'
Removes the login named MyLogin.
$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$serverObject | Remove-SqlDscLogin -Name 'MyLogin' -KillActiveSessions -Force
Removes the login named MyLogin after terminating any active sessions for the login.
Specifies that the login should be removed without any confirmation.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies that any active sessions for the login should be terminated before attempting to drop the login. This is useful when the login has active connections that would otherwise prevent the drop operation.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies a login object to remove.
Type: Login
Parameter Sets: LoginObject
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: FalseSpecifies the name of the server login to be removed.
Type: String
Parameter Sets: ServerObject
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies that the ServerObject's logins should be refreshed before trying to remove the login object. This is helpful when logins could have been modified outside of the ServerObject, for example through T-SQL. But on instances with a large number of logins it might be better to make sure the ServerObject is recent enough, or pass in LoginObject.
Type: SwitchParameter
Parameter Sets: ServerObject
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies current server connection object.
Type: Server
Parameter Sets: ServerObject
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: FalsePrompts 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: FalseShows 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: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.