commands

^

Remove-DbaLogin

Author Chrissy LeMaire (@cl), netnerds.net
Availability Windows, Linux, macOS

 

Want to see the source code for this command? Check out Remove-DbaLogin on GitHub.
Want to see the Bill Of Health for this command? Check out Remove-DbaLogin.

Synopsis

Drops a Login

Description

Tries a bunch of different ways to remove a Login or two or more.

Syntax

Remove-DbaLogin
    [-SqlCredential <PSCredential>]
    [-Force]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Remove-DbaLogin -SqlInstance <DbaInstanceParameter[]>
    [-SqlCredential <PSCredential>] -Login <String[]>
    [-Force]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Remove-DbaLogin
    [-SqlCredential <PSCredential>] -InputObject <Login[]>
    [-Force]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Remove-DbaLogin -SqlInstance sql2016 -Login mylogin

Prompts then removes the Login mylogin on SQL Server sql2016

Example: 2
PS C:\> Remove-DbaLogin -SqlInstance sql2016 -Login mylogin, yourlogin

Prompts then removes the Logins mylogin and yourlogin on SQL Server sql2016

Example: 3
PS C:\> Remove-DbaLogin -SqlInstance sql2016 -Login mylogin -Confirm:$false

Does not prompt and swiftly removes mylogin on SQL Server sql2016

Example: 4
PS C:\> Get-DbaLogin -SqlInstance server\instance -Login yourlogin | Remove-DbaLogin

Removes mylogin on SQL Server server\instance

Required Parameters

-SqlInstance

The target SQL Server instance or instances.

Alias
Required True
Pipeline false
Default Value
-Login

The Login(s) to process - this list is auto-populated from the server. If unspecified, all Logins will be processed.

Alias
Required True
Pipeline false
Default Value
-InputObject

A collection of Logins (such as returned by Get-DbaLogin), to be removed.

Alias
Required True
Pipeline true (ByValue)
Default Value

Optional Parameters

-SqlCredential

Allows you to login to servers using alternative credentials.

Alias
Required False
Pipeline false
Default Value
-Force

Kills any sessions associated with the login prior to drop

Alias
Required False
Pipeline false
Default Value False
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message. This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting. Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

Alias
Required False
Pipeline false
Default Value False
-WhatIf

Shows what would happen if the command were to run. No actions are actually performed.

Alias wi
Required False
Pipeline false
Default Value
-Confirm

Prompts you for confirmation before executing any changing operations within the command.

Alias cf
Required False
Pipeline false
Default Value