Rename-Computer: Syntax and Examples for Renaming Local & Remote Machines

The Rename-Computer cmdlet renames computers in Windows PowerShell. You can use this command to rename both local and remote computers.

Command Syntax

When renaming a local computer, the only required parameter is -NewName to specify the new name for the computer. An optional parameter is -Restart which forces a restart of the computer.

Rename-Computer -NewName <NewComputerName>
Rename-Computer -NewName <NewComputerName> -Restart

Two additional parameters need to be used when renaming a remote computer:

  • -ComputerName: Use the parameter -ComputerName to specify the IP address or domain name of the remote computer.
  • -DomainCredential or -LocalCredential depends on whether the computer is on a Domain controller or Workgroup.
Rename-Computer -ComputerName <IP/Name> -NewName <NewComputerName> -DomainCredential <user-name>
Rename-Computer -ComputerName <IP/Name> -NewName <NewComputerName> -LocalCredential <user-name>

Optionally, you may want to use the -Force parameter to execute the Rename-Computer command on the remote computer without requiring user confirmation.

Rename-Computer -ComputerName <IP/Name> -NewName <NewComputerName> -DomainCredential <user-name> -Force

Note that after renaming a computer, you will need to restart Windows for the changes to take effect.

Parameters

-ComputerNameUse this parameter to specify the IP address or domain name of a remote computer.
-DomainCredentialUse this parameter in a domain controller environment to specify a user account that has permission to rename the computer.
-ForceRun the command without asking for user confirmation.
-LocalCredentialWhen renaming a computer that is not on a domain, use this option to specify a local user account that has permission to connect to the remote computer.
-NewNameSpecifies the new name for the computer.
-PassThruWhen this option is used, it displays the result of the command.
-RestartRestarts the computer after the command is executed.
-ConfirmPrompts for confirmation before executing the command.

Examples

Change the name to 'Desktop-01' and restart the computer:

Rename-Computer -NewName Desktop-01 -Restart

Rename a remote computer in a domain environment:

Rename-Computer -ComputerName Desktop-01 -NewName Desktop-02 -DomainCredential example.com\administrator -Force -Restart

Rename a remote computer in a local network:

Rename-Computer -ComputerName 192.168.100.10 -NewName Desktop-01 -LocalCredential 192.168.100.10\user1

Click the following link to learn how to fix the 'The RPC server is unavailable' error: https://www.configserverfirewall.com/powershell/cannot-establish-the-wmi-connection-to-the-computer/

Find help for the Rename-Computer Cmdlet

To view the full documentation of the Rename-Computer command, run the following command:

Get-Help Rename-Computer -Full

Run the following command to display the list of parameters:

Get-Help Rename-Computer -Parameter *

The following command displays examples of how to use the Rename-Computer cmdlet:

Get-Help Rename-Computer -Examples