Author | Mitchell Hamann (@SirCaptainMitch) |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Rename-DbaLogin on GitHub.
Want to see the Bill Of Health for this command? Check out Rename-DbaLogin.
Rename-DbaLogin will rename logins
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.
Rename-DbaLogin will rename logins and database mappings for a specified login if Force is specified.
Rename-DbaLogin
[-SqlInstance] <DbaInstanceParameter[]>
[[-SqlCredential] <PSCredential>]
[-Login] <String>
[-NewLogin] <String>
[-Force]
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
PS C:\> Rename-DbaLogin -SqlInstance localhost -Login DbaToolsUser -NewLogin captain
SQL Login Example
PS C:\> Rename-DbaLogin -SqlInstance localhost -Login domain\oldname -NewLogin domain\newname
Change the windowsuser login name.
PS C:\> Rename-DbaLogin -SqlInstance localhost -Login dbatoolsuser -NewLogin captain -WhatIf
WhatIf Example
Source SQL Server.You must have sysadmin access and server version must be SQL Server version 2000 or greater.
Alias | |
Required | True |
Pipeline | false |
Default Value |
The current Login on the server - this list is auto-populated from the server.
Alias | |
Required | True |
Pipeline | false |
Default Value |
The new Login that you wish to use. If it is a windows user login, then the SID must match.
Alias | |
Required | True |
Pipeline | false |
Default Value |
Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.
For MFA support, please use Connect-DbaInstance.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Will attempt to rename any associated database users.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
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 |
Shows what would happen if the command were to run. No actions are actually performed.
Alias | wi |
Required | False |
Pipeline | false |
Default Value |
Prompts to confirm actions
Alias | cf |
Required | False |
Pipeline | false |
Default Value |