Powershell 远程计算机不执行程序

Powershell 远程计算机不执行程序,powershell,powershell-2.0,Powershell,Powershell 2.0,以下是我到目前为止的情况: $source1="C:\Folder\Files\IPList.txt" Get-Content $source1 | Where-Object {-not(gwmi win32_process -ComputerName $_ -filter "name='Program.exe'")} | Foreach-Object {Invoke-Command -ComputerName $_ -ScriptBlock {"C:\Program Files\Folder\

以下是我到目前为止的情况:

$source1="C:\Folder\Files\IPList.txt"
Get-Content $source1 |
Where-Object {-not(gwmi win32_process -ComputerName $_ -filter "name='Program.exe'")} |
Foreach-Object {Invoke-Command -ComputerName $_ -ScriptBlock {"C:\Program Files\Folder\Folder\Program.exe"}}
当我在ISE中运行它时,一切都恢复正常,并说它运行正确。然而,当我查看我的远程机器时,没有执行任何操作。Process Program.exe未运行,应启动该exe的程序。我正在从服务器上运行此命令,以命中大约50台远程计算机。一旦它通过全部50个循环,我将循环它并让它再次执行,然后在无限循环中继续这个过程

远程启动程序缺少什么?顺便说一下,我在Server2008R2上运行这个脚本,它正在运行Windows7机器

编辑

我想知道,因为我可以看到进程启动,这是Windows7的问题吗?我知道微软改变了事情,服务无法在用户空间启动应用程序。您认为这是同一问题的一部分吗?

尝试将call(&)操作符添加到脚本块:

$source1="C:\Folder\Files\IPList.txt"
Get-Content $source1 |
Where-Object {-not(gwmi win32_process -ComputerName $_ -filter "name='Program.exe'")} |
Foreach-Object {Invoke-Command -ComputerName $_ -ScriptBlock {& "C:\Program Files\Folder\Folder\Program.exe"}}

这里有一篇关于各种可用方法的好文章:

在您当前的语法中,您传递的命令只是一个字符串!这就是远端发生的情况:

PS C:\> "C:\Program Files\Console2\Console.exe"
C:\Program Files\Console2\Console.exe
Powershell正在回显您的字符串

我将引用Oliver Lipkau在这里提到的话:

如果需要在远程计算机上启动在脚本完成后仍在运行的进程,请使用以下功能:


我读了链接,谢谢你。我也尝试了你的建议并添加了&。我可以看到它现在正试图启动,但是过程结束了,它再也不会启动。“我可以看到它正在尝试启动”你能描述一下你看到了什么吗?您是否看到.exe显示在进程列表中?
Function New-Process ([string]$computername, [string]$name) {   
  ([WMICLASS]"\\$computername\ROOT\CIMV2:win32_process").Create($name) 
}