Rename an computer. PowerShell 3.0+
Syntax Rename-Computer [-NewName] String [-ComputerName String] [-Confirm] [-DomainCredential PSCredential] [-Force] [-LocalCredential PSCredential] [-PassThru] [-Protocol {DCOM | WSMan}] [-Restart] [-WhatIf] [-WsmanAuthentication {Default | Basic | Negotiate | CredSSP | Digest | Kerberos}] [CommonParameters] Key -ComputerName String Rename the specified remote computer. The default is the local computer. Type the NetBIOS name, an IP address, or a fully qualified domain name of a remote computer. To specify the local computer, type the computer name, a dot (.), or localhost. This parameter does not rely on PowerShell remoting. You can use the -ComputerName parameter of Rename-Computer even if your computer is not configured to run remote commands. -Confirm Prompt for confirmation before running the cmdlet. -DomainCredential PSCredential Specify a user account that has permission to connect to the domain. Explicit credentials are required to rename a computer that is joined to a domain. Type a user name, such as User64 or Domain64\User64, or enter a PSCredential object, such as one generated by the Get-Credential cmdlet. If you type a user name, this cmdlet prompts you for a password. To specify a user account that has permission to connect to the computer that is specified by the ComputerName parameter, use the LocalCredential parameter. -Force Force the command to run without asking for user confirmation. -LocalCredential PSCredential Specifies a user account that has permission to connect to the computer specified by the ComputerName parameter. The default is the current user. Type a user name, such as User64 or Domain64\User64, or enter a PSCredential object, such as one generated by the Get-Credential cmdlet. If you type a user name, this cmdlet prompts you for a password. To specify a user account that has permission to connect to the domain, use the DomainCredential parameter. -NewName String Specify a new name for the computer. This parameter is required. The name cannot include control characters, leading or trailing spaces, or any of the following characters: / \\ [ ]. -PassThru Return the results of the command. Otherwise, this cmdlet does not generate any output. -Protocol String Specifies which protocol to use to rename the computer. The acceptable values for this parameter are: WSMan and DCOM. The default value is DCOM. -Restart Restart the computer that was renamed. A restart is often required to make the change effective. -WhatIf Show what would happen if the cmdlet runs. The cmdlet is not run. -WsmanAuthentication String The mechanism that is used to authenticate the user credentials when this cmdlet uses the WSMan protocol. The acceptable values for this parameter are: - Basic - CredSSP - Default - Digest - Kerberos - Negotiate The default value is Default. CommonParameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable, -OutBuffer, -PipelineVariable, -OutVariable.
Standard Aliases for Rename-Computer: none
Rename-Computer renames the local computer or a remote computer. It renames one computer in each command.
Examples
Rename the local computer and then restart it:
PS C:\> Rename-Computer -NewName "Server064" -DomainCredential ss64dom\Admin64 -Restart
Rename a remote computer, note that both local and domain credentials are required:
PS C:\> Rename-Computer -ComputerName "Srv01" -NewName "Server066" -LocalCredential Srv01\Admin01 -DomainCredential ss64dom\Admin64 -Force -PassThru -Restart
Rename multiple computers:
PS C:\> $ServerList = Import-Csv ServerNames.csv -Header OldName, NewName
PS C:\> Foreach ( $Server in $ServerList ) {Rename-Computer -ComputerName $Server.OldName -NewName $Server.NewName -DomainCredential ss64dom\Admin64 -Force -Restart}
“Everything is impossible until it is done” ~ Robert H. Goddard (on possible future travel to the moon), 1921
Related PowerShell Cmdlets:
Remove-Computer - Remove the local computer from a workgroup or domain.
Restore-Computer - Restore the computer to a previous state.