让Windows加入域的PowerShell
$domain = "midrange.lab"
$password = "MyPassword!" | ConvertTo-SecureString -asPlainText -Force
$username = "$domain\administrator"
$credential = New-Object System.Management.Automation.PSCredential($username,$password)
Add-Computer -DomainName $domain -Credential $credential
来源
========================
Join Computer to Domain With Powershell (One-Click Method)