There are some different ways to join Windows 7 to a domain. You can do it manually, use djoin.exe to do it offline, use powershell, or use netdom.exe.
- Doing so manually can get cumbersome when you have a lot of different computers to do it on.
- With Djoin.exe you will have to run it on a member computer already joined to the domain for EACH computer you want to join since it will create a computer object in AD for each computer before hand.
- Powershell is OK to use, but you have to set the script to unrestricted before hand on EACH computer.
- Netdom is the way to go since you prep once for the domain, then run the script with Administrator privledges on whatever computers you want to join on the domain. Netdom doesn’t come on most versions of Windows 7 by default. There are two versions of netdom.exe, one for x86 and one for x64. You can obtain netdom.exe by installing Remote Server Administration Tools (RSAT) for Windows 7, and then copying netdom.exe to a share.
A quick way to deal with both x86 and x64 architectures in the same domain would be to make two scripts. One for x86 and one for x64 and have the appropriate netdom.exe in two different spots \\server\share\x86\ and \\server\share\x64\.
You’ll need to either grab netdom.exe from a version of windows 7 that already has it, or you’ll need to install RSAT for either x64 or x86 Windows 7 from here: http://www.microsoft.com/en-us/download/details.aspx?id=7887, which ever you will be working with. Install that on a staging computer. The following steps are how to get netdom.exe from the RSAT installation.
- Download and install RSAT for either x64 or x86.
- Follow the help file that opens after install for enabling features.
- Enable the following feature: Remote Server Administration Tools > Role Administration Tools > AD DS and AD LDS Tools > AD DS Tools > AD DS Snap-ins and Command-Line Tools
netdom.exe will now be under C:\windows\system32
Create a share readable by everybody on the domain, and drop netdom.exe there.
Create a script with the following (From: http://social.technet.microsoft.com/Forums/en/ITCG/thread/6039153c-d7f1-4011-b9cd-a1f111d099aa):
@echo off
SET netdomPath=c:\windows\system32
SET domain=domain.net
CALL BATCH.BAT %passwd%
CALL BATCH.BAT %adminUser%
SET sourcePath=\\fileshare\folder\::If necessary, copy netdom to the local machine
IF EXIST c:\windows\system32\netdom.exe goto join
COPY %sourcePath%netdom.exe %netdomPath%
COPY %sourcePath%dsquery.exe %netdomPath%
COPY %sourcePath%dsrm.exe %netdomPath%:Join
::Join PC to the domain
NETDOM JOIN %computerName% /d:%domain% /UD:%adminUser% /PD:%passwd%SHUTDOWN -r -t 0
Change domain and sourcepath to their real places. Remove dsquery.exe and dsrm.exe if not needed. If you’re just joining a domain, and not running anything after, then you don’t need them.
Create another script called “BATCH.BAT” that will hold your credentials that have access to joining computers to the domain. Put BATCH.BAT in both places that house your Join-To-Domain script (…/x86 and …/x64)
@echo off
SET passwd=thisismypassword
SET adminuser=thisismyadminusername
- Ensure you have the scripts in the same directory.
- Open up a command prompt with Administrator privledges and change directory to the location of your scripts.
Runnning the first script will:
- Run a check to see if netdom, dsquery, and dsrm are installed under system32, if they are, it will then join the domain, if not it will attempt to download them from your share.
- Once it ensures it has the files it needs, it will join the computer to the domain under the “Computers” OU with its current computer name using the credentials set by BATCH.BAT.
- It will reboot when done.
This will work on both Server 2003 and Server 2008.