2012-01-16 53 views
3

這樣得到遠程計算機上運行的應用程序的列表:如何使用PowerShell的

get-process -computername cname | where-object {$_.mainwindowhandle -ne 0} | select-object name, mainwindowtitle 

實在不行

+2

你得到了什麼錯誤? – Arcass 2012-01-16 14:06:18

+0

[如何使用PowerShell獲取遠程計算機上正在運行的應用程序的列表?](http://stackoverflow.com/questions/8881439/how-to-get-list-of-running-applications-on-remote-計算機使用PowerShell) – jpaugh 2016-12-12 22:56:19

回答

2

如果你得到空值的mainwindowtitle是正確的東陽這個屬性不avalaible用於遠程過程。請參閱MSDN以獲取NotSupportedException

1

如果可以,請使用PowerShell遠程處理。也就是說,您需要PowerShell V2,並且需要使用Enable-PSRemoting -Force在遠程系統上啓用PowerShell遠程處理。一旦你與之後,你應該能夠在遠程系統上像這樣運行命令:

 
$cred = Get-Credential 
Invoke-Command -ComputerName $computer {Get-Process *mail* | Where {$_.MainWindowHandle} | Select Name,MainWindowTitle} -Cred $cred 

如果你在一個領域,你的憑據是在遠程系統上有效的,你不需要通過-Credentials參數指定它們。

+0

運行時出錯:Invoke-Command - 計算機名$計算機{Get-Process * mail * |其中{$ _。MainWindowHandle} |選擇Name,MainWindowTitle} ....你可以試試 – 2012-01-17 13:22:09

+0

我在發佈之前嘗試過。你遇到了什麼錯誤?爲了正確設置PSRemoting可能有點棘手。 – 2012-01-17 14:43:41