use*_*632 6 powershell credentials invalidoperationexception
由于各种新的安全策略,我们需要能够作为分配的 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 脚本需要提升权限,但我已经以管理员身份运行。
我在这里可能会错过什么?
小智 2
当您的 PowerShell 会话以管理员身份使用管理员帐户登录时,您的问题就会消失。这将为您提供活动会话中缺少的提升权限。如果您的脚本在服务器上运行时遇到问题并且需要额外的帮助,那么这个解决方案就可以工作。 https://blogs.msdn.microsoft.com/virtual_pc_guy/2010/09/23/a-self-elevating-powershell-script/
GLHF!
| 归档时间: |
|
| 查看次数: |
23998 次 |
| 最近记录: |