/OfflineDomainJoin

Script to join a device offline during task sequence

Primary LanguagePowerShell

Domain Join Script

Description

This domain join script was design to support offline domain join capability and post SCCM domain join.

Use cases

  • Task Sequence for both MDT/SCCM
  • Offline Domain Join (ODJ)
  • Pre Windows Join in PE (Unattend)
  • Post WinPE Join (Windows)

Offline Domain Join

This feature allows the script to use a offline domain join blob or File generated by a Domain Controller to join a system to the domain. This feature works in both WinPE during pre setup and Post setup. Presetup will apply the blob content to the Unattend file. The post setup will run the djoin command

Unattend

This feature is very similar to the way SCCM or MDT applies the domain join; it adds the domain details to the targeted Unattend.xml file. This feature works both Pre Windows setup (during WinPE) adn Windows Post setup, however it will initiate the sysprep command in post

Windows

This feature allows a device to join the domain using the Add-Computer cmdlet. This is the default feature and only works in Post WinPE...when Windows is running.

Examples

Join the domain using Task Sequence variables on while running in Windows

DomainJoin.ps1

Apply domain info to unattend file; typically done during pre windows. if done during Windows the sysprep parameter will be added

DomainJoin.ps1 -JoinMethod Unattend -DomainJoinName contoso.com -Join contoso\admin -JoinPassword P@$$w0rd12

Join a device to the domain while logged into windows using credentials

DomainJoin.ps1 -JoinMethod Windows -DomainJoinName contoso.com -Join contoso\username -JoinPassword P@$$w0rd12 -Restart

Join a device to the domain using a ODJ blob file from a network share uniquely identified by model and serial number

DomainJoin.ps1 -JoinMethod ODJ -JoinODJBlobFile \\server01\share01\ODJ\%model%_%serialnumber%.odj -Restart

Join a device to the domain using a ODJ blob data

DomainJoin.ps1 -JoinMethod Unattend -JoinODJBlob 'ARAIAMzMzMxIAwAAAAAAAAAA...'

Variables

These variables are used during a Task Sequence and will preset the value for most parameters.

  • OfflineDomainJoinBlob --> this is custom variable; sets the value for -JoinODJBlobFile parameter
  • OfflineDomainJoinFile --> this is custom variable; sets the value for -JoinODJBlob parameter
  • OSDComputerName --> sets the ComputerName variable; not a parameter
  • _SMSTSMachineName --> sets the ComputerName variable if OSDComputerName is not found; not a parameter
  • OSDJoinDomainName --> sets the value for -JoinDomainName parameter
  • OSDJoinAccount --> sets the value for -JoinUsername parameter
  • OSDJoinPassword --> sets the value for -JoinPassword parameter
  • OSDJoinDomainOUName --> sets the value for -JoinDomainOU parameter
  • OSDisk --> sets the OSDisk variable; not a parameter

Exit Codes

  • 0 --> Successfully joined the domain; reboot may be required
  • -1 --> Not all required parameters where provided
  • -2 --> Domain Join failed. Check DomainJoin.log or enable debug and check c:\Windows\Logs\JoinDomain.log