How to rename computer using "Rename-Computer" PowerShell Cmdlet
Once the Windows Server Operating System is installed, you may need to change the default random computer name generated by the Windows Server setup program. Before renaming the computer, you may need to view the current name of the Windows Server. You can view the current computer name (before renaming the computer) by running the PowerShell Cmdlet "Get-ComputerInfo" or hostname command in Command Prompt.
You may need to rename a Windows Server using PowerShell, if you have a Server Core installation.
How to find the current computer name in a Server Core installation
We can use the PowerShell Cmdlet "Get-ComputerInfo" to get the current computer name. Run the PowerShell Cmdlet Get-ComputerInfo -Property CsName from the PowerShell terminal, to get the current computer name.
Please refer below image.
You may also use the "hostname" command from the Command Prompt, to find the current computer name.
Please refer below image.
You can see from the above images that the default computer name generated in a Windows Server computer during installation is a random string starting with "WIN–".
To rename a Windows Server to a meaningful name, we can use the PowerShell cmdlet "Rename-Computer". Use the following format to rename a Windows Server computer, using PowerShell cmdlet Rename-Computer -NewName "OMNISECU-08". The default random computer name generated during the installation will be changed to OMNISECU-08, after running the above PowerShell Cmdlet.
You need to restart the computer after changing the computer name.
To restart the computer, use the PowerShell Cmdlet "Restart-Computer" from the PowerShell terminal. Please refer the following image.
Once the server is restarted after renaming the computer name using "Rename-Computer" PowerShell Cmdlet, you can find the changed computer name by running PowerShell Cmdlet "Get-ComputerInfo -Property CsName" again. You can find the computer name is renamed to "OMNISECU-08", as shown in below image.
Written by Jajish Thomas.
Last updated on 29th May, 2024.