ComputerName为的powershell获取进程缺少路径
我想在某台远程计算机上的特定文件夹下获取进程列表,并将其杀死。然而,若我添加-ComputerName,Get进程并并没有按预期返回Path,所以我无法使用Path返回Where。是否有办法在远程计算机上以特定路径获取进程/停止进程ComputerName为的powershell获取进程缺少路径,powershell,Powershell,我想在某台远程计算机上的特定文件夹下获取进程列表,并将其杀死。然而,若我添加-ComputerName,Get进程并并没有按预期返回Path,所以我无法使用Path返回Where。是否有办法在远程计算机上以特定路径获取进程/停止进程 // Paths are filled PS C:\> Get-Process | Format-Table Name, Path Name Path
// Paths are filled
PS C:\> Get-Process | Format-Table Name, Path
Name Path
---- ----
firefox C:\Program Files (x86)\Mozilla Firefox\firefox.exe
// Paths are empty
PS C:\> Get-Process -ComputerName localhost | Format-Table Name, Path
Name Path
---- ----
firefox
如果在远程服务器上启用了远程处理,则可以使用,并在命令的脚本块中执行操作:
Invoke-Command -ComputerName remoteComputer -Script { param($pathFilter) Get-Process | ?{$_.Path -like $pathFilter} | Format-Table Name, Path } -Args "somefilter*"