小编use*_*632的帖子

以管理员身份运行 PS,但收到错误 - 该操作需要提升

由于各种新的安全策略,我们需要能够作为分配的 uid 运行各种任务。为了帮助实现这一点,开发了一个通用菜单系统。脚本中的函数之一是:

$credential = user_credential
$cmd = "C:\windows\system32\mmc.exe" 
$args = "C:\Windows\System32\compmgmt.msc"
Start-Process -FilePath $cmd -ArgumentList $args  -Credential $credential
Run Code Online (Sandbox Code Playgroud)

收到错误:

Start-Process : This command cannot be run due to the error: The requested operation requires elevation.
t C:\webeng\webeng.ps1:131 char:5
     Start-Process -FilePath $cmd -ArgumentList $args  -Credential $credential
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
   + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
Run Code Online (Sandbox Code Playgroud)

该错误似乎表明 PS 脚本需要提升权限,但我已经以管理员身份运行。

我在这里可能会错过什么?

powershell credentials invalidoperationexception

6
推荐指数
1
解决办法
2万
查看次数