Worked out how to script install of .msu updates.
$filename = "C:\temp\log\WUInstall_" + $timer + ".evtx"
Start-Process -FilePath wusa -ArgumentList "\\fs1\software\WS2012R2\windows8.1-kb4041693-x64_31e473824b705bf05f3befc423d39fa0c6d0fb49.msu /quiet /norestart /log:$filename" -Wait
Using wusa with Powershell as this is the only way to avoid a machine restart after the update - as I need to wait for this one to complete and run a couple more commands, before issuing a manual restart (/norestart
requires /quiet
as well).
Not able to log the outcome of the installation to a clear-text format, it's .evtx only.
Let's just say that the update is already installed (could be an already patched OS image, no control over this) and I run the script. It just runs, no error.
When executed without /quiet /norestart
it will eventually print "<..> is already installed on this computer."
Also, in .evtx log there are a few lines that show the status of the install process, including "InstallWorker.01090: Update is already installed". But I have no knowledge on how to parse this log. I can only parse a plain text log.
Is there a way to parse the .evtx log ? so that I can put some logic in my script to check the status (update installed ok or not) and decide on an action ? (move to next step in the script or quit with error)
Or a better solution to solve this in Powershell 5.1 ? Should be able to apply it to WS 2012 through 2016.