Powershell远程脚本执行问题

Powershell远程脚本执行问题,powershell,powershell-remoting,Powershell,Powershell Remoting,我正在尝试从主机1.2.3.3远程执行机箱1.2.3.4上的powershell脚本 $cred = get-credential $process = get-wmiobject -query "SELECT * FROM Meta_Class WHERE __Class = 'Win32_Process'" -namespace "root\cimv2" -computername 1.2.3.4 -credential $cred $results = $process.Create(

我正在尝试从主机1.2.3.3远程执行机箱1.2.3.4上的powershell脚本

$cred = get-credential 
$process = get-wmiobject -query "SELECT * FROM Meta_Class WHERE __Class = 'Win32_Process'" -namespace "root\cimv2" -computername 1.2.3.4 -credential $cred 
$results = $process.Create("powershell.exe /c C:\Windows\temp\hello.ps1 arg1") 
我可以看到进程正在被创建(返回值为0),但进程在远程系统中立即停止(1.2.3.4)

我也尝试了powershell.exe-file选项,而不是powershell.exe/c

我尝试使用Invoke命令,但由于受信任的主机问题,该命令无效。
有人能解释一下吗?

PowerShell.exe参数以破折号开头(例如“-”),要获得完整帮助,请键入:PowerShell.exe/


你预计会发生什么?剧本在做什么?它应该这样“死”吗?

我正试图安装一个可执行文件。在powershell脚本中,我将从共享位置访问exe并安装它。另外,我尝试了-file选项而不是/c,但也不起作用。您得到的退出代码是新创建进程的退出代码,不是安装过程的退出代码我在打印变量$results\uuuuuu GENUS:2\uuuuuu CLASS:\uuuuuuu PARAMETERS\uuuuuu SUPERCLASS:\uuuuuu PARAMETERS\uuuuuu RELPATH:\uuuuu属性\u COUNT:2\uuuuuu派生:{}时引用的是退出代码__服务器:_命名空间:_路径:ProcessId:6336 ReturnValue:0确切地说,您得到的是创建成功的返回值,而不是PowerShell进程的退出代码。请检查此帖子