Once you have installed Windows Server or a Windows 10 desktop machine, you will need to change the default name of the computer (hostname
). It is usually recommended to include its location or role in the hostname, like mun-dc01, wks-skmIT13, MUNTG02, etc. Also, You can use the serial or inventory number of the device as the computer name.
During the installation, Windows generates a computer name, for example, DESKTOP-P12DNFQ
. The hostname contains 15 characters, the first seven characters are taken from your organization name, and the rest are randomly generated. For a home computer, the name is not usually important, but if a computer is located in an organization and works as a part of a workgroup or an AD domain, it is better to set a meaningful computer name. In this article, we will show you how to rename a Windows machine hostname.
A computer name must meet the following requirements:
- Must not exceed 15 characters;
- It must not include any special characters (
< > ; : » * + = \ | ? ,
). Dashes and underscores can be used; - It must not contain only numbers;
- A computer name is not case-sensitive;
- If the computer is to be joined to an Active Directory domain, the computer name must be unique within the domain.
Change the Name of a Computer Using the Windows GUI
In the latest versions of Windows 10 and 11, you can use the Settings panel to rename your computer.
- Press
Win+I
and go to System -> About (you can use thems-settings:about
URI command to quickly access the Settings); - Click Rename this PC;
- Enter a new computer name and click Next;
- Restart your computer to apply the changes.
You can also change the hostname from the classic System Properties interface in Windows:
- Press
Win+R
keyboard shortcut and runsysdm.cpl
orsystempropertiescomputername
command; - Here you will see the current name of your computer and your domain or workgroup name;
- Click Change, enter a new computer name, and save the changes.
- Restart Windows.
You can change the computer name using the Server Manager on Windows Server. Open the Local Server section and click the name in the Computer Name box.
How to Rename a Computer with PowerShell
You can rename a computer from the command prompt using the Rename-Computer PowerShell cmdlet.
Open a PowerShell console as an administrator. Check the current hostname using the command
$env:computername
Or:
hostname
If you want to get the computer’s FQDN:
$env:computername.$env:userdnsdomain
To change the computer name:
Rename-Computer -NewName "WKS-SKMO12S3"
Then you can restart the machine using the Restart-Computer command (or you can add a restart option to the command):
Rename-Computer -NewName WKS-SKMO12S3 –Restart -Force
After the reboot, check that the computer name has been successfully changed.
If this computer was a member of the Active Directory domain and was located in an OU (Organization Unit) before the name change, its computer account will still be in the same container, but with a new name. You can check this using the ADUC console. To rename a computer in AD, your account must be delegated permissions to create and delete computer objects in that OU.
The Rename-Computer cmdlet allows to change the name of a remote machine:
Rename-Computer -ComputerName "mun-test" -NewName "mun-preprod02" -DomainCredential woshub\maxbak_adm –Force
WMI is used to connect to the remote computer, so if it is disabled on the remote host or the network ports are blocked, an error will occur:
Rename-Computer : Cannot establish the WMI connection to the computer ‘priorauthdes’ with the following error message: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
You can use PowerShell Remoting commands to connect to a remote computer. If you have manually enabled Windows Remote Management or configured WinRM by using GPO on a remote computer, you can use the Invoke-Command to run a command on a remote computer. To change the name of a remote computer, run the following command:
Invoke-Command -ComputerName mun-test -ScriptBlock { Rename-Computer -NewName mun-preprod02 –Restart -Force}
Previously, the netdom command was used to change the machine’s hostname:
- Rename a local computer:
netdom renamecomputer localhost /newname mun-preprod02 /reboot
- Rename a remote computer:
netdom renamecomputer mun-test /newname:mun-preprod02 /userd:woshub\maxbak_adm /password:*
You can change a computer name on Windows Server Core by using the built-in pseudo-graphical sconfig
tool.