Powershell 启动进程 : This command cannot be executed due to the error: Access is denied

标签 powershell access-denied start-process

我正在尝试从具有给定凭据的 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/

相关文章:

当与 Windows 服务环境中的 Credential 一起使用时,powershell Start-Process 退出代码 -1073741502

powershell - 有没有办法通过 start-process 将可序列化对象传递给 PowerShell 脚本?

powershell - 如果使用 -Wait 参数运行,如何更改 powershell 中进程的优先级?

powershell - 如何确定Microsoft故障转移群集是否具有仲裁(在Powershell中)

powershell - 使用 PowerShell 返回整个 select 语句

c# - 当 Process.Kill() 产生 "access denied"因为进程正在终止时,我该如何处理?

C++ 将 2 个字符串合并在一起

powershell - 无法从PowerShell脚本写入默认的Inno Setup日志文件

Powershell 固定宽度导出

Javascript "SCRIPT5: Access is denied"从脚本打开 PDF