I am trying to install MSU through below PowerShell script, but its not getting installed. I am not aware of PowerShell scripting. Please someone give me best way to modified this script. I am looking forward to hear.
Start-Process "C:\Installer\windows10.0-kb4520062-x64_9f2a827f11f945d19bd26de6f113f611a38bb8a1.msu" -ArgumentList "/quiet /norestart"
In order to be able to pass arguments to a process launched via
Start-Process
, the (possibly positionally implied)-FilePath
argument must be a true executable, not just a document, which is what a.msu
file is.Therefore, you must pass the executable that
.msu
files are registered to be processed by explicitly to-FilePath
, which iswusa.exe
(note the/quiet /norestart
at the end of the-ArgumentList
argument):Note:
In order to wait for the installation to finish, add the
-Wait
switch.To additionally check the process' exit code in order to determine whether the installation succeeded, add the
-PassThru
switch, capture the resulting process-info object in a variable, and then check its.ExitCode
property.However, there is a trick that simplifies the above: pipe the
wusa.exe
call toWrite-Output
, which forces it to execute synchronously (as a GUI-subsystem application,wusa.exe
would otherwise run asynchronously) and also records its exit code in the automatic$LASTEXITCODE
variable: