Powershell 将域计算机用户添加到本地管理员
我有两台机器,比如在公司域Powershell 将域计算机用户添加到本地管理员,powershell,active-directory,powershell-2.0,powershell-remoting,Powershell,Active Directory,Powershell 2.0,Powershell Remoting,我有两台机器,比如在公司域CorpotateDomain中。 第一台机器:First.CorpotateDomain.com 第二个:Second.CorpotateDomain.com 我想使用powershell将第一台计算机的PrimUser添加到第二台计算机的administrators组。 然后我想使用shutdown实用程序或stop computercmdlet从第一台计算机关闭第二台计算机(使用PrimUser登录)。(例如,远程重启iis) 是否可能,我应该使用什么命令将域用户
CorpotateDomain
中。
第一台机器:First.CorpotateDomain.com
第二个:Second.CorpotateDomain.com
我想使用powershell将第一台计算机的PrimUser
添加到第二台计算机的administrators组。
然后我想使用shutdown
实用程序或stop computer
cmdlet从第一台计算机关闭第二台计算机(使用PrimUser
登录)。(例如,远程重启iis
)
是否可能,我应该使用什么命令将域用户添加到管理员
p、 美国。
我试过:
您可以将域用户添加到本地管理组,但我认为您不能添加另一台计算机的本地用户
$user=[ADSI]"WinNT://domain/PrimUser"
$group=[ADSI]"WinNT://./Administrators"
$group.Psbase.Invoke("Add",$user.Psbase.path)
将$user设置为用户的可分辨名称,类似于
CN=PrimUser,CN=Users,DC=CorporateDomain,DC=com
我可以使用windows控制面板将域用户添加到本地管理员,因此,我认为应该是通过powershell实现的方法
$user=[ADSI]"WinNT://domain/PrimUser"
$group=[ADSI]"WinNT://./Administrators"
$group.Psbase.Invoke("Add",$user.Psbase.path)