How to add administrators remotely in Powershell

Powershell remote add administrator

Write-Host "Add a remote administrator, please enter the host and AD domain account"
$DomainName = "XXX.com"
$ComputerName = Read-Host "Computer name:"
$UserName = Read-Host "User name:"
$AdminGroup = [ADSI]"WinNT://$ComputerName/Administrators,group"
$User = [ADSI]"WinNT://$DomainName/$UserName,user"
$AdminGroup.Add($User.Path)


Guess you like

Origin blog.51cto.com/11258494/2590888