
Renaming a Computer and Automating the Domain Join
Renaming a computer and joining it to an AD domain is very easy through the GUI. To automate the process, PowerShell and netdom are available, among other tools.
1 min read
Renaming a computer and joining it to an AD domain is very easy through the GUI. To automate the process, PowerShell and netdom are available, among other tools.
PowerShell
The “Rename-Computer” cmdlet can be used to rename a computer (locally or remotely) and restart it in the same step. A user with the appropriate permissions must be passed with the -LocalCredential or -DomainCredential parameters:
Rename-Computer -NewName <NAME> -DomainCredential <DOMAIN\User> -Restart -Force
Alternatively, you can rename the computer with Add-Computer and then join it to a domain (or optionally a workgroup):
Add-Computer -DomainName <DOMAIN> -NewName <NAME> -Force -Restart [-OUPath "<OU-PATH>"]
netdom
Of course, the process can also be done without PowerShell:
netdom renamecomputer %ComputerName% /NewName:<NAME> /userd:<USER> /passwordd:<PASSWORD> /reboot:5
netdom join %ComputerName% /domain:<DOMAIN> /userd:<USER> /passwordd:<PASSWORD> /reboot:5