Sometimes you need to install a list of hotfixes, provided as *.MSU files by Microsoft. KB articles already installed will, by default, fail.

In this blog post, I provide a Powershell script you can use to install a list of MSU files.

What are MSU files?

A *.msu file, or a Microsoft Update file is a packaged used by Microsoft Update. This file is installed using the stand-alone installer wusa.exe. The stand-alone installer is run automatically when installing an update through Microsoft Update, but it can also be triggered manually.

What is wusa.exe?

Wusa.exe can be found in the %WinDir%\System32 folder and contain the following data:

Windows Update metadataDescribes each update package that the .msu file contains.

One or more .cab filesEach .cab file represents one update.

An .xml fileThis .xml file describes the .msu update package. Wusa.exe uses the .xml file when you perform an unattended installation of the update by using the Package Manager tool (Pkgmgr.exe).

For example, you download hotfix 934307. The Windows6.0-KB934307-x86.msu file is in the C:\934307 folder. You type the following command at a command prompt to expand the .msu file to a temporary folder:

expand -f:* “C:\934307\Windows6.0-KB934307-x86.msu” %TEMP%
Then, you type the following command at a command prompt:

pkgmgr.exe /n:%TEMP%\Windows6.0-KB934307-x86.xml
A properties fileThis file contains string properties that Wusa.exe uses. For example, this file contains the title of the associated article in the Microsoft Knowledge Base.


Install MSU files using a Powershell script

The Powershell script below takes the KB articles on the list and only install those not already installed.

Just change the Powershell script according to your requirements.

#Source folder
$SourceFolder = "c:\temp"

#Crete new Powershell object
$KBArrayList = New-Object -TypeName System.Collections.ArrayList 

#Mofify KB article list

foreach ($KB in $KBArrayList) { 
    if (-not(Get-Hotfix -Id $KB)) { 
        Start-Process -FilePath "wusa.exe" -ArgumentList "$SourceFolder$KB.msu /quiet /norestart" -Wait } 

Related Posts



Please enter your comment!
Please enter your name here