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


Rename-DbaLogin

Rename-DbaLogin will rename login and database mapping for a specified login.

There are times where you might want to rename a login that was copied down, or if the name is not descriptive for what it does.

It can be a pain to update all of the mappings for a specific user, this does it for you.

Screenshots

Examples

SQL Login Example

Rename-DbaLogin -SqlInstance localhost -Login DbaToolsUser -NewLogin captain

Change the windowsuser login name.

Rename-DbaLogin -SqlInstance localhost -Login domain\oldname -NewLogin domain\newname

WhatIf Example

Rename-DbaLogin -SqlInstance localhost -Login dbatoolsuser -NewLogin captain -WhatIf

Author

This command was created by Mitchell Hamann. You can find Mitchell on Twitter.

Get-Help

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

Source Code

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

Related commands