Renaming a Computer using PowerShell

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

About the author

Johan Arwidmark

0 0 votes
Article Rating
Subscribe
Notify of
guest
6 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
rosin
rosin
1 year ago

Does it also change the fullname?
What if you also want to change the full name?

Vuyo
Vuyo
1 year ago

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 ?

Vuyo
Vuyo
2 months ago

Hi Johan

Noted, please share the script when you are done.


>