我正在尝试从具有给定凭据的 powershell 脚本运行 start-process。
尽管如此,命令失败并出现以下错误:
Start-Process : This command cannot be executed due to the error: Access is denied
这是完整的错误日志:
18-Jun-2015 11:48:54 Start-Process : This command cannot be executed due to the error: Access is den
18-Jun-2015 11:48:54 ied.
18-Jun-2015 11:48:54 At C:\Windows\system32\config\systemprofile\AppData\Local\Temp\PRISMA-AMR-JOB1-
18-Jun-2015 11:48:54 87-ScriptBuildTask-8569094554411403512.ps1:38 char:18
18-Jun-2015 11:48:54 + Start-Process <<<< C:\Windows\System32\cmd.exe -arg "/C" -Credential $cr
18-Jun-2015 11:48:54 edential
18-Jun-2015 11:48:54 + CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOp
18-Jun-2015 11:48:54 erationException
18-Jun-2015 11:48:54 + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
18-Jun-2015 11:48:54 ommands.StartProcessCommand
这是有问题的 powershell 调用的样子:
Start-Process C:\Windows\System32\cmd.exe -arg "/C" -Credential $credential
如果我在执行脚本的机器上使用适当的凭据打开命令提示符,运行
cmd /C
做得很好。如果它代表 start-process 在 powershell 脚本上,它就会失败。也许我应该说,当我使用目标凭据手动运行命令提示符时,我以管理员身份登录,而 powershell 看起来是在系统帐户下运行的。
看起来某些权限确实有问题......知道这里发生了什么吗?
编辑:
从里面所说的
https://serverfault.com/questions/185813/which-ad-permission-is-required-to-allow-impersonation-of-an-account/193717#193717
我在本地策略 -> 用户权限分配中检查了模拟权限。系统存在,为了完整起见,我还添加了计算机帐户。重新启动。但是没有运气,问题仍然存在!
最佳答案
好的,我终于明白了。
似乎出于安全原因,系统帐户无法发起模拟。
这里的解决方案是将运行脚本的帐户从系统更改为自定义帐户。然后允许在安全策略中模拟此帐户,如下所示:
https://serverfault.com/questions/185813/which-ad-permission-is-required-to-allow-impersonation-of-an-account/193717#193717
关于Powershell 启动进程 : This command cannot be executed due to the error: Access is denied,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30912320/