How to Rename a Computer or Server with PowerShell

There is a plethora of reasons a computer or server might need to be renamed. It could be due to a reorg, a merger, or simply to clean up asset tracking. Regardless, changing the name of a computer or server is really simple, especially with PowerShell.

Renaming a computer can be done using the Rename-Computer command in PowerShell. This cmdlet can be used to rename both local and remote computers and can be automated with use of scripting for bulk changes.

The Rename-Computer cmdlet has a NewName parameter which specifies the new name for the target computer.

Here is the syntax for the Rename-Computer cmdlet:

Rename-Computer [-NewName] <System.String> [-ComputerName <System.String>] [-DomainCredential
    <System.Management.Automation.PSCredential>] [-Force] [-LocalCredential
    <System.Management.Automation.PSCredential>] [-PassThru] [-Protocol {DCOM | WSMan}] [-Restart]
    [-WsmanAuthentication {Default | Basic | Negotiate | CredSSP | Digest | Kerberos}] [-Confirm] [-WhatIf]
    [<CommonParameters>]

You can pull up this syntax list yourself by opening PowerShell and entering “Get-Help Rename-Computer

Here is a description of the parameters:

  • -NewName: Specifies the new name for the computer. It is required to rename a computer. The name can contain alphanumeric characters and hyphens (-).
  • -ComputerName: Specifies the remote computer to be renamed. The default value is the local computer. To specify a remote computer, use the IP address, domain name, or NetBIOS name of the computer. To specify the local computer, type the computer name, a dot (.), or “localhost”
  • -DomainCredential: Specifies a user account that has permission to connect to a remote computer in the domain and rename it. Use the format Domain\User or use the Get-Credential cmdlet to get the user credentials.
  • -Force: This parameter forces the command to execute without user confirmation.
  • LocalCredential: Same effect as DomainCredential but uses an account on the local machine rather than the domain.
  • PassThru: Returns the results of the command within the PS prompt window.
  • -Restart: Specifies that the computer should be restarted after it is renamed in order to apply the new name system wide in Windows.
  • WhatIf: Shows (simulates) what changes will be made should you run the command string.

Now, let’s look at some examples that use the Rename-Computer cmdlet.

Rename a Local Computer

To rename a local computer, use the following command:

Rename-Computer -NewName "NPGPC1" -Restart

This will rename the local computer to NPGPC1 and restart it to reflect the changes.

Rename a Remote Computer

To rename a remote computer, use the following command:

Rename-Computer -ComputerName "NPGPC1" -NewName "NPGPC2" -Restart

This will rename the remote computer NPGPC1 to NPGPC2 and restart it to commit the changes.

Rename a Computer on a Domain

To rename a computer on a domain, you must have permission to connect to the domain. You can use explicit credentials with the DomainCredential parameter and the Get-Credential cmdlet.

An example of renaming a computer on a domain would be:

Rename-Computer -ComputerName "NPGPC1" -NewName "NPGPC2" -DomainCredential NPGDOM\DomAdmin -Force

This will rename the remote computer NPGPC1 to NPGPC2 on the domain, using the user account NPGDOM\DomAdmin for explicit credentials. The Force parameter will execute the command without a prompt for user confirmation.

Considerations and Repercussions When Renaming a Computer or Server

Before you go willy-nilly renaming computers in your environment, be mindful of the following:

  • The name needs to comply with your organization’s naming conventions.
  • The new name needs to be unique, so it doesn’t interfere with domain and application connectivity with another computer on the domain.
  • Make sure there are no existing DNS or DHCP entries for the name you are about to use that may cause an IP conflict once renamed.
  • Verify the user account you are using has permission to rename computers on the domain.
  • Be mindful of any services or applications that depend on the computer’s name and be sure they are updated with the new name post change.
  • Make sure any mapped drives or connections to the computer are updated with the new name.
  • Make sure any services or applications that depend on the computer’s name are updated with the new name. This may include services that use a service principal name (SPN) or Kerberos delegation.
  • If you’re renaming a remote computer, make sure your method of remote connectivity will continue to work or allow you to reconnect to the computer once it is renamed.
  • If the computer has any group policy objects (GPOs) applied to it verify they are updated with the new computer name otherwise they may quit functioning properly. Double check group policy health with gpresults after renaming.
  • The computer’s security identifier (SID) will be changed, which may cause issues with access to resources, application, and anything else that is coded to rely on the SID.
  • If you’re using any remote monitoring and management (RMM) utilities or the like, make sure they are updated with the new name, so you don’t lose track of the computer.
  • If the computer or server is physical and has an asset tag, you’ll need to update this so your asset tracking doesn’t get jacked.

Recommended for You: Solarwinds Hybrid Systems Monitoring Bundle

Know which applications are having issues in your environment before users complain? Know which systems are causing those problems or were recently changed by someone? How about which servers are about to have problems like running out of space or memory?

Automate collection of data and alerting on your local or cloud applications and servers with Solarwinds Hybrid Systems Bundle so you have these answers.

Get insight into Active Directory, DNS, DHCP, and your Virtual and Applications environments, both locally and cloud hosted, without needing to mess with complex templates or knowing a single line of code.

Chase Smith, CCNP

Chase Smith, CCNP is a Network Engineer III who has spent the last decade elbow deep in enterprise system administration and networking. He can usually be found trying to warm up behind the storage in the datacenter.

Leave a Reply

Your email address will not be published. Required fields are marked *