dbatools is a free PowerShell module with over 300 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


Remove-DbaLogin

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

Screenshots

dbatools-Remove-DbaLogin

Examples

Prompts then removes the Login mylogin on SQL Server sql2016.

Remove-DbaLogin -SqlInstance sql2016 -Login mylogin

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

Remove-DbaLogin -SqlInstance sql2016 -Login mylogin, yourlogin

Does not prompt and swiftly removes mylogin on SQL Server sql2016.

Remove-DbaLogin -SqlInstance sql2016 -Login mylogin -Confirm:$false

Removes mylogin on SQL Server server\instance

Get-DbaLogin -SqlInstance server\instance -Login mylogin | Remove-DbaLogin

Author

This command was created by Chrissy LeMaire. You can find Chrissy on Twitter.

Get-Help

From PowerShell, execute Get-Help Remove-DbaLogin -Detailed for more information on this function.

Source Code

Want to see the source code? View Remove-DbaLogin.ps1 on GitHub
 

Related commands