I have two machines, say in the company domain CorpotateDomain
.
First machine: first.CorpotateDomain.com
Second: second.CorpotateDomain.com
I want to add PrimUser
from the first one to administrators group for second machine using powershell.
And then i want to shutdown second machine from the first one (login using PrimUser
) using the shutdown
utility or stop-computer
cmdlet. (Or, for example, restart iis
remotely)
Is it possible, and what command should i use to add domain users to admins?
p.s. i tried:
$user = "WinNT://first.CorpotateDomain.com/PrimUser"
$group = New-Object System.DirectoryServices.DirectoryEntry("WinNT://./Administrators")
$group.PSBase.Invoke("Add",$user)
You can add a domain user to the local admin group but i don't think you can add a local user of another computer.
$user=[ADSI]"WinNT://domain/PrimUser"
$group=[ADSI]"WinNT://./Administrators"
$group.Psbase.Invoke("Add",$user.Psbase.path)