Join a machine to a domain and rename using PowerShell

Easily rename computers and join them to domains using PowerShell

John Savill

January 21, 2016

1 Min Read
ITPro Today logo

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(s)

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like