Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 将域计算机用户添加到本地管理员_Powershell_Active Directory_Powershell 2.0_Powershell Remoting - Fatal编程技术网

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)