How to Change Computer Name (Hostname) in Windows | Windows OS Hub (2024)

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.

Contents:

  • Change the Name of a Computer Using the Windows GUI
  • How to Rename a Computer with PowerShell

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.

  1. Press Win+I and go to System -> About (you can use the ms-settings:about URI command to quickly access the Settings); How to Change Computer Name (Hostname) in Windows | Windows OS Hub (1)
  2. Click Rename this PC;
  3. Enter a new computer name and click Next; How to Change Computer Name (Hostname) in Windows | Windows OS Hub (2)
  4. Restart your computer to apply the changes.

You can also change the hostname from the classic System Properties interface in Windows:

  1. Press Win+R keyboard shortcut and run sysdm.cpl or systempropertiescomputername command;
  2. Here you will see the current name of your computer and your domain or workgroup name; How to Change Computer Name (Hostname) in Windows | Windows OS Hub (3)
  3. Click Change, enter a new computer name, and save the changes. How to Change Computer Name (Hostname) in Windows | Windows OS Hub (4)
  4. 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 Change Computer Name (Hostname) in Windows | Windows OS Hub (5)

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

How to Change Computer Name (Hostname) in Windows | Windows OS Hub (6)

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

How to Change Computer Name (Hostname) in Windows | Windows OS Hub (7)

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.

How to Change Computer Name (Hostname) in Windows | Windows OS Hub (8)

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.

If you are deploying a reference Windows image to computers using automated installation tools (WDS, SCCM, or over the network using PXE), you can add a small script to them to automatically change a computer name according to your organization’s naming policies.

How to Change Computer Name (Hostname) in Windows | Windows OS Hub (2024)
Top Articles
Latest Posts
Article information

Author: Errol Quitzon

Last Updated:

Views: 6363

Rating: 4.9 / 5 (79 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Errol Quitzon

Birthday: 1993-04-02

Address: 70604 Haley Lane, Port Weldonside, TN 99233-0942

Phone: +9665282866296

Job: Product Retail Agent

Hobby: Computer programming, Horseback riding, Hooping, Dance, Ice skating, Backpacking, Rafting

Introduction: My name is Errol Quitzon, I am a fair, cute, fancy, clean, attractive, sparkling, kind person who loves writing and wants to share my knowledge and understanding with you.