Add a machine to Microsoft Windows Domain with PowerShell

Add a machine to Microsoft Windows Domain with PowerShell

I've been trying to learn more about PowerShell and use it more frequently. I recently decided to script adding a server to a domain via PowerShell.

Here is the command-

add-computer –domainname ad.contoso.com -Credential AD\\adminuser -restart –force

Once entered you will be prompted to enter admin credentials.