This blog post describes how to join a computer to the domain by using the graphical user interface or running a simple One-Liner in Powershell.
Testing the Environment
Run PowerShell with administrative privileges. First, check IP-Address, Default Gateway and DNS Server Settings. The DNS Server must point to one of your Domain Controller. To verify name resolution run Test-Connection with your Domain Name.
Test-Connection pagr.inet -Quiet
True. That looks good. Now we can move on. But wait a minute: If you get a False, then you have to troubleshoot that issue. There is no way out, unless you configure your DNS settings and your network connectivity properly. To do so, check your DNS Server Settings and your connectivity to one of your Domain Controller.
Join the Computer to the Domain
Graphical User Interface
Press Windows Key + Pause (Break).
Next click Change Settings.
Select Change. Then provide your domain name. Important information: It´s not a good idea to change the computername and join the computer to the domain at the same time.
Click OK. Next enter your domain credentials. (User must have permissions to join the domain).
Restart the Computer and log on to the domain by using the format: domain\user. (for example: pagr\petra).
Add-Computer
You can also run Add-Computer to join your computer to the domain. Provide the username and password of a member of the Domain Admins Group.
Add-Computer -DomainName pagr.inet -DomainCredential pagr\administrator
Next restart your computer and log in to the domain.
Restart-Computer
Optional: Once logged in, check the secure channel to one of your Domain Controllers by using Test-ComputerSecureChannel.
Test-ComputerSecureChannel -Verbose
What have we learned from that? The return value True is a positive sign 😉
Further thoughts
Note: By default, every Domain User is allowed to join up to 10 computers to the domain. For changing this standard setting see my article Securing Active Directory: Who can add computers to the domain? Only the domain admin. Are you sure?
Categories: PowerShell, Windows Server
Hi, i would like to be able to change the name of the computer, join the domain and restart in one line. Is it possible that i could get it to prompt for the name change of the computer. the reason for this is that i have 50 computers to deploy without the help of a WDS server or any deployment equipment.Any help would be greatly appreciated
LikeLike
Have a look at the help of Add-Computer. This may help you on your way.
LikeLike
How can I join a computer to the Domain and same time write computer name via PowerShell?
LikeLike
You can use $env:computername
LikeLike
thanks
LikeLike