[英]PowerShell Invoke-Command with Start-Process outputs different result
[英]PowerShell Invoke-Command with Start-Process access denied
我有一个包含以下代码的脚本:
$secpasswd = ConvertTo-SecureString "Ukn545454" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ("$env:USERDOMAIN\user1", $secpasswd)
invoke-command -ComputerName "MyW10comp" -ScriptBlock {Start-proccess -FilePath PowerShell.exe -Credential $using:mycreds}
我有 8 台计算机,(其中一台也是 w10 但 32 位),并且在每个计算机上脚本运行良好,但在其中的 Windows 10 64 位上它说:
This command cannot be run due to the error: Access is denied.
+ CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
+ PSComputerName : MyW10Comp
如果我在本地运行脚本,一切顺利! 我可以在计算机上检查什么以查看问题所在?
谢谢
这听起来像是一个双跳问题。 考虑到您的会话已经在您的上下文中运行,我不明白您为什么要启动传递凭据的进程:
$cred = [pscredential]::new(
'domain\user',
('pass' | ConvertTo-SecureString -AsPlainText -Force)
)
Invoke-Command -ComputerName MyW10comp -Credential $cred -ScriptBlock {
Start-Process -FilePath cmd
}
这个例子应该可以解决你的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.