Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/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,在win 10中,以下行运行正常,但在windows 8上返回: 错误:调用方法失败,因为 [System.Security.Principal.WindowsPrincipal]不包含方法 名称为“新” 错误:无法调用空表达式方法 旧版本的powershell不支持::新语法 你必须求助于: 旧版本的powershell不支持::新语法 你必须求助于: $windowsID = [System.Security.Principal.WindowsIdentity]::GetCurrent()

在win 10中,以下行运行正常,但在windows 8上返回:

错误:调用方法失败,因为 [System.Security.Principal.WindowsPrincipal]不包含方法 名称为“新”

错误:无法调用空表达式方法

旧版本的powershell不支持::新语法

你必须求助于:

旧版本的powershell不支持::新语法

你必须求助于:

$windowsID = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$windowsSecurityPrincipal = [System.Security.Principal.WindowsPrincipal]::new($windowsID)
$adminRole = [System.Security.Principal.WindowsBuiltInRole]::Administrator
$windowsSecurityPrincipal = New-Object -TypeName System.Security.Principal.WindowsPrincipal -ArgumentList $windowsID