$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)
来源:https://www.cnblogs.com/awpatp/p/4549171.html