Join a Computer To an Active Directory Domain Using PowerShell
In this blog post, I will show you how I join a Windows machine (Windows 10 or Server) to an Active Directory domain using a PowerShell script.
The following script is using an Administrator account to join the domain, and before it joins the domain, it asks for the password (of the administrator).
Save the script is.PS1 and run it from the machine.
$User = "corp\administrator" $pass = Read-Host -Prompt "Set Password" -AsSecureString #use code below if you don't want password prompt (not recommanded to hard code password #$Pass= ConvertTo-SecureString -String "TYPEPassword" -AsPlainText -Force $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord add-computer –domainname corp.ntweekly.com -Credential $Credential -restart –force
When you run the script, you will see the command prompt, as shown below.
To deploy and Active Directory domain using PowerShell visit the following post.
via Learn IT and DevOps By Doing https://ift.tt/33GXxQZ
July 18, 2020 at 10:16AM