Windows — Rename Computer via PowerShell
Fresh installs get names like DESKTOP-K3J9X2F — useless the moment you manage more than one machine. Rename-Computer changes the hostname from PowerShell, locally or remotely, without clicking through System Properties. One cmdlet, one reboot, done.
This guide uses PowerShell throughout because it is scriptable and identical across Windows 10, 11, and Server. The GUI route (Settings → System → About → Rename this PC) exists and is fine for a one-off on your own desktop.
Before You Rename — What a Name Change Touches
On a standalone home PC, renaming is harmless. On anything other machines talk to, check these first:
- DNS / static entries — anything resolving the old name (router DNS entries, Pi-hole/AdGuard rewrites,
hostsfiles on other machines) needs updating. - Network shares & mapped drives — paths like
\\old-name\shareon other machines break. - Certificates — certs issued to the old hostname stop matching. Relevant for RDP certs and anything with internal CA-issued certs.
- Monitoring & backup agents — tools like Uptime Kuma checks or backup jobs that target the hostname will report the machine as missing.
- Domain-joined machines — the rename must propagate through Active Directory; plan it, don't squeeze it between meetings.
None of this is a reason not to rename — just rename first, fix the references immediately after, and you avoid an afternoon of mysterious failures.
Pre-requisites
- PowerShell running as Administrator
- For domain-joined machines: domain credentials with permission to rename computer objects
Naming Rules
- Letters (
a–z,A–Z), digits (0–9), and hyphens (-) — no spaces, no dots - Not entirely digits
- Maximum 63 characters (DNS limit)
- Practical limit: 15 characters — longer names get truncated to 15 for NetBIOS, which older Windows networking and AD still use. Staying within 15 avoids a machine that has two different names depending on who asks.
Check the Current Hostname
Rename the Local Machine
The machine renames itself and reboots immediately — the new name is only active after the restart.
To stage the change and reboot later (running updates first, finishing other work):
The old name stays active until the next reboot. Restart when convenient:
Rename a Remote Computer
Rename-Computer can target another machine directly — this uses WMI under the hood and does not require PowerShell remoting to be enabled on the target:
Rename-Computer -ComputerName "old-hostname" -NewName "new-hostname" -LocalCredential old-hostname\Administrator -Restart
-LocalCredential is the account that may connect to the target machine — you are prompted for its password. Without -Restart, the remote machine keeps its old name until someone reboots it.
Rename a Domain-Joined Machine
Renaming a machine that is joined to a domain additionally requires credentials allowed to update the computer object in AD:
You are prompted for the password when passing a plain username.
AD propagation
After the reboot, allow a few minutes for the change to replicate through Active Directory before connecting to the new name. The old name may still resolve from DNS caches in the meantime — ipconfig /flushdns on the connecting machine helps.
Verify After Reboot
On a domain, confirm the computer object was updated:
Common Issues
| Symptom | Cause | Fix |
|---|---|---|
Access is denied on a domain machine |
Missing -DomainCredential or account lacks rights on the computer object |
Pass domain credentials with rename permission |
Skip computer ... because the new name ... is invalid |
Name violates the rules above | Letters, digits, hyphens; not all digits; ≤ 63 chars |
| Other machines still reach the old name | DNS caches | ipconfig /flushdns on the clients; check static DNS entries |
| New name works locally, fails over the network | Name > 15 characters, NetBIOS truncation | Use a name with 15 characters or fewer |
| RDP certificate warning after rename | Self-signed RDP cert was issued to the old name | Windows regenerates it; accept once, or delete the old cert under Remote Desktop in certlm.msc |