How to Rename a Computer or Server with PowerShell | NetworkProGuide (2024)

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. These steps are applicable to any Windows 10, Windows 11, or Windows Server machine.

Related:

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.

In some situations, you may need to enable PS Remoting on the remote computer before it will accept PowerShell connections. You do this with:

Enable-PSRemoting -Force

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.

Rename a Workgroup Computer

For computers that are members of a workgroup you can use the -LocalCredential parameter. For example, open a PowerShell console as administrator and enter:

Rename-Computer -ComputerName "NPGPC1" -NewName "NPGPC2" -LocalCredential NPGPC1\Admin -Force

Renaming Multiple Computers with a CSV File

You can import a csv file into PowerShell to programmatically rename a list of computers. To do this, set up a csv file with a row containing the original name and new name you wish to use for each computer. For example:

How to Rename a Computer or Server with PowerShell | NetworkProGuide (2)

We can then use the following script to import the file and loop through the list using the commands shared earlier:

$File = 'c:\rename-computers-list.csv' //path to your csv file$Credential=Get-Credential$computerList= Import-Csv -Path $File -Delimiter "," -Header OldName,NewNameforeach ($Computer in $computerList){Rename-Computer -ComputerName $Computer.OldName -NewName $Computer.NewName -DomainCredential $Credential -Force -Restart}

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 Tool: SolarWinds Hybrid Systems Monitoring Bundle

  • Application and dependency monitoring
  • Supports hybrid cloud environments
  • Detailed visibility from application to spindle
  • Monitor Azure and AWS IaaS, PaaS, and SaaS
  • Automatic application and infrastructure discovery
  • PerfStack dashboard for performance correlation
  • AppStack dashboard for application dependency
How to Rename a Computer or Server with PowerShell | NetworkProGuide (2024)
Top Articles
Latest Posts
Article information

Author: Stevie Stamm

Last Updated:

Views: 6365

Rating: 5 / 5 (80 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Stevie Stamm

Birthday: 1996-06-22

Address: Apt. 419 4200 Sipes Estate, East Delmerview, WY 05617

Phone: +342332224300

Job: Future Advertising Analyst

Hobby: Leather crafting, Puzzles, Leather crafting, scrapbook, Urban exploration, Cabaret, Skateboarding

Introduction: My name is Stevie Stamm, I am a colorful, sparkling, splendid, vast, open, hilarious, tender person who loves writing and wants to share my knowledge and understanding with you.