Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.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 - Fatal编程技术网

如何使用PowerShell将您的用户名添加到管理员?

如何使用PowerShell将您的用户名添加到管理员?,powershell,Powershell,如何使用powershell使自己成为电脑管理员 例外情况: Cannot find group name + $AdminGroup.Add($InUser.Path) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], ExtendedTypeSystemException + FullyQualifiedErrorId : CatchFromBaseGetMembe

如何使用powershell使自己成为电脑管理员

例外情况:

Cannot find group name + $AdminGroup.Add($InUser.Path) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], ExtendedTypeSystemException + FullyQualifiedErrorId : CatchFromBaseGetMember
您可以通过查询内置\Administrators组SID的
Win32\u group
来发现组名:

$AdministratorsGroupName=(获取CimInstance-ClassName Win32_Group-Filter'SID=“S-1-5-32-544”)。名称
# ...
$AdminGroup=[adsi]“WinNT://$HostName/$AdministratorsGroupName,组”
$User = $env:USERNAME
$HostName = $env:COMPUTERNAME
$DomainName = "xxxx"
$AdminGroup = [ADSI]"WinNT://$HostName/administrators,group"
$InUser = [ADSI]"WinNT://$DomainName/$User,user"
$AdminGroup.Add($InUser.Path)