Change Computer Name – Windows CMD & PowerShell

To show a computer’s name in Windows, simply execute the hostname command from a Windows command prompt (CMD) or PowerShell.

There may be multiple reasons to rename the computer.

In this article, i will show you how to change your computer’s name in Windows using the CMD and PowerShell.

Change Computer Name in Windows

Rename Computer using PowerShell

The name of the computer can be changed from the elevated PowerShell using the Rename-Computer command.

Press ⊞ Win + X to open the Start menu flyout and then click on “Windows PowerShell (Admin)”.

Enter the following PowerShell’s command, substituting <NewHostname> with your preferred name, and press the “Enter” to rename the computer:

PS C:> Rename-Computer -NewName "<NewHostname>"
- sample output -
WARNING: The changes will take effect after you restart the computer <OldHostname>.

Restarted the computer to complete the name changing.

Change Hostname using CMD

Alternatively, you can change the computer’s name from the elevated Windows command prompt (CMD).

Press ⊞ Win keybutton to open the Start menu, type in cmd to search for the command prompt and press Ctrl + Shift + Enter to start the CMD as administrator.

To change the computer’s hostname, execute the following command from the elevated Windows command prompt:

C:> wmic computersystem where name="%computername%" call rename name="<NewHostname>"
- sample output -
Executing (\\<OldHostname>\ROOT\CIMV2:Win32_ComputerSystem.Name="<OldHostname>")->rename()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
        ReturnValue = 0;
};

As well as with the PowerShell, you need to restarted the computer to complete the name changing.

Leave a Reply