Joining a Computer to a Domain Using PowerShell


Using PowerShell scripts within a task sequence provides more flexibility than using the CustomSettings.ini file to join a computer to a domain. The parameters of the CustomSettings.ini file are common to any deployment you perform. That's why creating a custom PowerShell script to join your domain will be customize to only your environment, so the security risk is very low.

Here is the code to join a domain using PowerShell:

$strUser = "bjtech\Administrator"
$strDomain = ""
$strPassword = ConvertTo-SecureString "P@55w0rd" -AsPlainText -Force
$Credentials = New-Object System.Management.Automation.PsCredential $strUser,

Add-computer -DomainName $strDomain -Credential $Credentials

Once you have created your *.ps1 file and copy it to the script folder under your deployment share. You will then haveto call it within your Task sequence. I placed my PowerShell script command in the “Custom Task Node”. Open your Task Sequence > Click on Add > General > Run PowerShell Script

12-22-2015 12-38-43 AM
Within the PowerShell Command Line you will call the PowerShell Script within your script folder: %SCRIPTROOT%\BTNHD\JoinDomain.ps1

12-22-2015 12-40-32 AM

About BjTechNews (867 Articles)
An IT guy trying to learn everything about technology and sharing it with you all. I'm a blogger and video blogger who highlights daily news in the tech industry, promoting tips and hacks for fellow techies.

1 Trackback / Pingback

  1. Deploying a Windows 10 1607 Reference Image with Microsoft Deployment Toolkit 8443 | Stick To The Script!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s