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