Join a machine to a domain and rename using PowerShell
Easily rename computers and join them to domains using PowerShell
January 21, 2016
Q. How can I join a machine to a domain and rename it using PowerShell?
A. PowerShell version 3 introduces a -NewName parameter for Add-Computer which enables a machine to join and domain and have a new name set with a single command. This removes having to rename the machine using:
(Get-WmiObject win32_computersystem).Rename("$server")
The new command would therefore be:
Add-Computer -Credential cred -DomainName savilltech.net -NewName server;Restart-Computer -force
Note I also use Restart-Computer to complete the rename and domain join operation.
Each week, John Savill answers all of your toughest tech questions about the worlds of Windows Server, Azure, and beyond. Read his past IT advice here, and email your questions to [email protected].
About the Author
You May Also Like