powershell - WMICLASS.Create(), returning variables? -


in powershell, running process remotely (software install):

$computers = get-content "c:\computer.txt"  foreach ($computer in $computers) {   #the location of 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 install result local c drive     out-file -filepath c:\installed.txt -append -inputobject "$computer"}  

is there way return variables or status of install? or wait until process done?

locally, can use wait-process:

$installprocess = ([wmiclass]"win32_process").create($installstring) wait-process -id $installprocess.processid 

unfortunately, wait-process doesn't support remoting.


here's poor man's remote equivalent using get-process:

$installprocess = ([wmiclass]"\\$computer\root\cimv2:win32_process").create($installstring) { get-process -id $installprocess.processid -computername $computer } while ($?) 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -