Here is a short PowerShell snippet for renaming a domain joined computer using PowerShell. It can be run both locally, and remote.
# Sample script to rename a domain joined computer
$OldComputerName = "CHI1-W10VM-002"
$NewComputerName = "R824-002"
$Username = 'VIAMONSTRA\Administrator'
$Password = 'P@ssw0rd'
$pass = ConvertTo-SecureString -AsPlainText $Password -Force
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass
Rename-Computer -ComputerName $OldComputerName -NewName $NewComputerName -DomainCredential $Cred -Restart -Force
Does it also change the fullname?
What if you also want to change the full name?
Domain joined computer by default append the DNS Suffix, so yes this changes the full computer name as well.
/ Johan
What happens to the old computer name after renaming the computer ? Would it be possible to amend the script so that the new computer name overwrites the old computer name on Active Directory ?
Hi Vuyo,
It's a rename of the same computer object, so there is no old object to delete.
Hi Johan
Noted, please share the script when you are done.
Hi again,
I answered a bit too quickly. No need to remove the old object, it's the existing object that just gets renamed with a new name.