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

问题描述 投票:1回答:1

由于各种新的安全策略,我们需要能够以指定的uid运行各种任务。为了协助这一点,开发了一个通用的菜单系统。脚本中的一个功能是:

$credential = user_credential
$cmd = "C:\windows\system32\mmc.exe" 
$args = "C:\Windows\System32\compmgmt.msc"
Start-Process -FilePath $cmd -ArgumentList $args  -Credential $credential

收到错误:

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

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

我可能会在这里失踪什么?

powershell credentials invalidoperationexception
1个回答
0
投票

当您的PowerShell会话以管理员WHILE使用管理员帐户登录时,您的问题将会消失。这将为您提供活动会话中缺少的提升权限。如果您的脚本在服务器上运行并且需要额外的冲击,那么这个解决方案可以解决。 https://blogs.msdn.microsoft.com/virtual_pc_guy/2010/09/23/a-self-elevating-powershell-script/

GLHF!

© www.soinside.com 2019 - 2024. All rights reserved.