1
在PowerShell中,遠程運行的進程(軟件安裝):WMICLASS.Create(),返回變量?
$computers = Get-Content "C:\computer.txt"
foreach ($computer in $computers) {
#The location of the file
$Install = "\\$computer\C$\Software"
#The Install string can have commands aswell
$InstallString = "$Install\IE11-Windows6.1-x64-en-us.exe $arguments"
([WMICLASS]"\\$computer\ROOT\CIMV2:Win32_Process").Create($InstallString)
#Output the install result to your Local C Drive
Out-File -FilePath c:\installed.txt -Append -InputObject "$computer"}
有沒有辦法返回變量或本安裝狀態?或者等到這個過程完成了?
我嘗試這一點,但有一個不過程中發現的。你確定這可以在遠程PC上工作,或者是'Wait-Process'搜索本地PC嗎? – Zeno
@Zeno對不起,沒有注意到,更新回答 –
也沒有運氣,這是返回'Get-Process:無法連接到遠程機器.'即使該過程確實開始 – Zeno