Apply hotfixes during task sequence

If you want to apply hotfixes as part of a task sequence there are of course numerous ways to achieve this. Using PowerShell, MDT 2012 U1 (soon to be 2013??) with SCCM 2012 can make this look a lot prettier with just a few lines of code.

So, lets set this up.

1. First of all we need a script, named hotfixes.ps1. The code looks like this;

$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
$folder = $scriptPath
$total = gci $folder *.msu | measure | Select-Object -expand Count
$i = 0
gci $folder *.msu | foreach {
WUSA ""$_.FullName /quiet /norestart""
Write-Progress -activity "Applying Hotfixes" -status "Installing $_ .. $i of $total" -percentComplete (($i / $total) * 100)
Wait-Process -name wusa

2. Collect the hotfixes necessary into a folder. Place the script in the root, and the hotfixes in a sub-folder named “hotfix”. All hotfixes must be of the .MSU-kind.


3. Create a package of this to make the files available within the SCCM 2012 infrastructure


4. Create a new MDT 2012 Update 1 task sequence. Add the following steps;


As you can see below we set our script to be executed and reference the package which contains the updates


5. Deploy the task sequence to a computer and verify the results;


Looks nice? Well, the script is partly built on the ideas of Niklas Åkerlund, a fellow Swede, on howto install multiple Windows hotfixes. Using a forum-post response by Michael Niehaus I gathered that it would be rather simple to output it more nicely and provide insight into progress using the task sequence progress bar.

6 thoughts on “Apply hotfixes during task sequence

    • nickekallen Post authorReply

      Today I applied;
      143 security updates
      119 hotfixes
      + the rollup


  1. Marco Reply

    Thank you for this helpfull script! At first it wouldn’t work but found the issue.

    I changed:

    $folder = $scriptPath


    $folder = “$scriptPathhotfix”

    Otherwise the script should be placed in the same directory as the MSU’s.

    Thanks again for posting!



    • Tobias Heyl Reply

      I don’t get what you changed …
      Overall this is a bit of compressed, as I find it hard following the steps.

      In my case I’m running a SCCM task sequence, and I’m able to either add a PowerShell script using the regular components or add a MDT PowerShell script, whatever the difference is.

      Anyway’ I’m trying to add a single msu-file and would like to try if it works this time as a regular package didn’t do the trick 🙁 we’ll see if this runs. Thanks in advance!

  2. jason Reply

    Hi, I’m going to try this but i’m wondering if it’ll install the hotfixes in order lowest kb # to highest.
    thanks, jason

Leave a Reply

Your email address will not be published. Required fields are marked *