In this tutorial, I will explain how to rename a computer using PowerShell. Whether you are managing a network of computers or simply need to rename your personal machine, PowerShell provides a useful method for this. Let me show you how to rename a computer using PowerShell.
To rename a computer using PowerShell, use the Rename-Computer cmdlet with the -NewName parameter to specify the new computer name. For example, to rename a computer to “MyNewPC”, run the command: Rename-Computer -NewName “MyNewPC”. The command will prompt for confirmation before renaming the computer.
Why Rename a Computer?
Renaming a computer can be necessary for various reasons, such as:
- Standardizing naming conventions across a network.
- Improving organization and ease of identification.
- Reflecting changes in the computer’s role or ownership.
- Enhancing security by avoiding predictable names.
Prerequisites
Before we start, ensure you have:
- Administrative privileges on the computer you want to rename. This is very important, you should run PowerShell using admin mode.
- PowerShell installed (Windows PowerShell comes pre-installed on Windows 10 and later).
Rename a Computer Using PowerShell
Here is the step-by-step guide to renaming a computer using PowerShell.
Step 1: Open PowerShell with Administrative Privileges
- Click on the Start menu.
- Type PowerShell in the search bar.
- Right-click on Windows PowerShell and select Run as administrator.
Step 2: Check the Current Computer Name
Before renaming, it’s good practice to check the current name of the computer. Use the following command:
Get-ComputerInfo | Select-Object CsNameThis command retrieves the current computer name. For example, you might see something like DESKTOP-1234ABC.
On my computer, it is showing me like this here in the screenshot below:

Step 3: Rename the Computer
To rename the computer, use the Rename-Computer cmdlet. Here’s the basic syntax:
Rename-Computer -NewName "NewComputerName"Example 1: Rename a Personal Computer
Let’s say you want to rename your computer to JOHN-DESKTOP. Execute the following command:
Rename-Computer -NewName "JOHN-DESKTOP"Example 2: Rename a Workstation in a Company Network
If you are renaming a workstation for an employee named Jane Smith in the New York office, you might use:
Rename-Computer -NewName "NY-JSMITH-WKS"Step 4: Restart the Computer
For the changes to take effect, you need to restart the computer. You can do this using PowerShell as well:
Restart-ComputerThis will immediately restart the computer. Make sure to save any open work before executing this command.
Check out Get HP Laptop Model and Serial Number Using PowerShell
Rename a Remote Computer
If you need to rename a computer remotely, you can use the -ComputerName parameter. Ensure you have the necessary permissions and the remote computer is accessible.
Here is an example.
Rename-Computer -ComputerName "OLD-NAME" -NewName "NEW-NAME" -Credential (Get-Credential)This command will prompt you to enter credentials with administrative privileges on the remote computer.
Use a CSV File for Bulk Renaming
If you need to rename multiple computers, you can use a CSV file to automate the process. Create a CSV file (e.g., computers.csv) with two columns: OldName and NewName.
Example CSV Content
Here is an example of a .CSV file with old and new computer names.
OldName,NewName
OLD-LAPTOP-1,NEW-LAPTOP-1
OLD-DESKTOP-2,NEW-DESKTOP-2Then, you can use the below PowerShell Script for bulk renaming computers.
$computers = Import-Csv -Path "C:\MyFolder\computers.csv"
foreach ($computer in $computers) {
Rename-Computer -ComputerName $computer.OldName -NewName $computer.NewName -Credential (Get-Credential)
Restart-Computer -ComputerName $computer.NewName -Force
}This script reads the CSV file, renames each computer, and then restarts it.
Check out Get the Windows Version Using PowerShell
Common Errors while Renaming a Computer using PowerShell
- Access Denied: Ensure you are running PowerShell as an administrator and have the necessary permissions on the target computer.
- Computer Not Found: Verify the computer name and network connectivity.
- Invalid New Name: Ensure the new name adheres to naming conventions (e.g., no spaces or special characters).
Check the Rename Status of the Computer
After renaming the computer, you can verify the new name using the Get-ComputerInfo cmdlet:
Get-ComputerInfo | Select-Object CsNameThis should display the new computer’s name.
Conclusion
In this tutorial, I explained how to rename a computer using PowerShell, as well as how to rename bulk computers from a CSV file using PowerShell. You will get to know about the Rename-Computer cmdlet in PowerShell.
Bijay Kumar is an esteemed author and the mind behind PowerShellFAQs.com, where he shares his extensive knowledge and expertise in PowerShell, with a particular focus on SharePoint projects. Recognized for his contributions to the tech community, Bijay has been honored with the prestigious Microsoft MVP award. With over 15 years of experience in the software industry, he has a rich professional background, having worked with industry giants such as HP and TCS. His insights and guidance have made him a respected figure in the world of software development and administration. Read more.