2009-05-04 77 views
30

我正在編寫一個腳本,開始於PowerShell。我試圖轉換一個working VBScript script枚舉在遠程Windows計算機上映射的網絡驅動器。如何在PowerShell中使用輸出參數調用方法?

其中一個任務是使用遠程WMI來讀取註冊表並找到explorer.exe的進程所有者,以確定誰已登錄。這似乎很容易通過this guide

但是,我需要調用的WMI方法是GetOwner() from Win32_Process,它需要兩個輸出參數來存儲其返回值。

如何調用帶輸出參數的方法?當我嘗試給它兩個字符串時,出現錯誤:Cannot find an overload for "GetOwner" and the argument count: "2".。 MSDN頁面說有兩個參數,所以我不確定我在做什麼錯誤。

回答

9
$explorer = gwmi Win32_Process -computerName computerName -filter "Name='explorer.exe' and SessionID=0" 
$explorer.GetOwner() | select user,domain 
+0

甜! – spoulson 2009-05-05 19:55:58

相關問題