Powershell Domain Join Specific Ou
Add computer domainname domain cred domain administrator passthru oupath ou xxx dc domain dc domain.
Powershell domain join specific ou. This was introduced with powershell version 3 and can be used to automate imaging processes or to prompt an agent for the desired computer. The script will prompt for a username and password before it joins. I haven t tried creating a batch file but it could possibly work.
Type the netbios name an internet protocol ip address or a fully qualified domain name of each of the remote computers. In other way. Powershell gives you the ability to add computers to active directory right from the command line with the built in powershell commandlets.
3 users can choose their own ou for their domain join process so admin doesn t need to move thier computer objects to specific ou after domain join. Powershell script join a server to a specific ou in active directory. The one i liked most the reason why i wrote this script xp.
If the script fails it will generate an error. Powershell add computer domainname yourdomainhere ydh credential domain username oupath ou yourou ou yourou dc yourdc dc yourdc you can copy and paste into notepad to modify for you. Run this command to join a computer to the domain and specify the ou path.
Things you need to do. A powershell script to add a server to a specific ou when joining a domain. Function join domain param parameter position 0 string computername env computername parameter position 1 validateset ou computers ou chicago dc your dc domain dc here ou computers ou paris dc your dc domain dc here ou computers ou sydney dc your dc domain dc here ou computers ou toronto dc your dc domain dc here string ou cn computers ou chicago dc your dc domain dc here renamecomputer true if computername eq or.
To specify the local computer type the computer name a dot. The default is the local computer. Specifies the computers to add to a domain or workgroup.