Solved How you can join Windows 7 to a domain using batch file

August 9, 2013 at 22:33:16
Specs: Windows 7
Windows 7 does not include netdom by default. I scoured the net for hours looking for a simpler solution than this RSAT crap or what ever. Then powershell came up and that had its own bullcrappery errors which were more easily fixed than netdom however the solution to these errors were not in one place. SO to all those IT people out there im doin yall a favor here and putting everything in one location in as many forums as possible.

FOR JOINING A COMPUTER TO A DOMAIN WITHOUT NETDOM - (Windows 7... possibly others have not tested but i dont see why it wouldnt work)

First you create Two files BOTH are created using notepad.

type exactly as displayed or cut and paste i dont care. input your own information in the obvious locations if you cant figure that out sell your computer, you have no business owning one.

First file:

powershell -command "& {Set-ExecutionPolicy Remotesigned}"
powershell -file e:\domainjoin.ps1
powershell -file f:\domainjoin.ps1
powershell -file g:\domainjoin.ps1
powershell -file h:\domainjoin.ps1
powershell -file i:\domainjoin.ps1
powershell -file j:\domainjoin.ps1
powershell -file k:\domainjoin.ps1
powershell -file l:\domainjoin.ps1
powershell -file m:\domainjoin.ps1
powershell -file n:\domainjoin.ps1
powershell -file o:\domainjoin.ps1
powershell -file o:\domainjoin.ps1


Ok! So now Save As -------- DomainJoin.bat (file type all files not txt) put it .. somewhere easily accessed.

NOW Second file!

$domain = "yourdomain"
$password = "yourpassword" | ConvertTo-SecureString -asPlainText -Force
$username = "$domain\youraccount"
$credential = New-Object System.Management.Automation.PSCredential($username,$password)
Add-Computer -DomainName $domain -Credential $credential
Set-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy Restricted -Force

Okay! Save As - domainjoin.ps1 <--------- Pay attentionnnnnnnnnnnn! (again file type "all files" not .txt)

NOW for this save it on the root of what ever you use for media for example... "c:\domainjoin.ps1" or "f:domainjoin.ps1"

that is very important grass hoppers.

Alrighty you are ready to run the file. Right click on DomainJoin.bat and hit run as administrator

you will see a lot of errors fear not.

in the script i included just about all of the drive letters the file could be on, so as long as you put it on the root of the USB stick or C Drive you should be good (you can also add the drive letters i did not include)

Somewhere in those errors you should see something telling you a restart is required to apply settings. once it says hit any key to continue restart and you should be goooood to go!

See More: How you can join Windows 7 to a domain using batch file

Report •

August 10, 2013 at 08:38:25
Thanks for sharing. Does the forest/domain need to be at a certain level for this to work? What are all the errors in relation to? Also, in the script I dont see any sections for OU's, where does your script drop the workstation in AD?

Report •

August 11, 2013 at 10:53:42
✔ Best Answer
I did it at an AD functional level of server 12. havent tested it on any others, but i used no funky scripting codes so i dont see why it wouldnt work.

The default ou they get plopped in is "Computer" however i think there are some commands you can add to the script to specify what OU to put it in.

you can take a look at doing this (again i have not used this personally) -

you can also use wsname to script out renaming the computer if you so choose [i have not tested this site for the wsname app. the site i previously got it from is no longer in service]

Report •
Related Solutions

Ask Question