Join to domain powershell script
$username = "domain\admin"
$Password = "xxxxxxxx"
$pwd = $Password | ConvertTo-SecureString -asPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($UserName,$pwd)
$Domain = "domain.com"
Add-Computer -DomainName $Domain -Credential $credential –Restart