This blog is owned and operated by the ANZ ConfigMgr Premier Field Engineer team.
Ian BartlettMatt ShadboltGeorge Smpyrakis
Firstly, locate your most up to date image and make a copy of it. This is so we can stream the newest Windows Updates into the mounted WIM without risk of damaging a working WIM. I suggest copying the WIM to a temp location. Also, put the Windows Update that you want to apply into an Updates folder.
Next, mount your image in the temp location.
DISM /Mount-Wim /WimFile:C:\TempMount\install.wim /index:1 /Mountdir:C:\TempMount\Mount
Now inject the Windows Update you need to apply
DISM /image:C:\TempMount\Mount /Add-Package /Packagepath:C:\Updates\
Finally, save an unmount the image
DISM /Unmount-Wim /Mountdir:C:\TempMount\Mount /commit
While running updates manually like this is an easy way to apply a few updates, hundreds of updates require more work. Here’s how you would apply the updates using PowerShell.
$UpdatesPath = "C:\Updates\*"
$MountPath = “C:\TempMount\Mount”
$WimFile = “C:\TempMount\install.wim”
DISM \Mount-Wim /WimFile:$WimFile /index:1 /Mountdir:$MountPath
$UpdateArray = Get-Item $UpdatesPath
ForEach ($Updates in $UpdateArray)
DISM /image:$MountPath /Add-Package /Packagepath:$Updates
Start-Sleep –s 10
Write-Host "Updates Applied to WIM"
DISM /Unmount-Wim /Mountdir:$MountPath /commit
Using SCCM 2007 Deployment Packages makes getting these updates really simple. Package up the updates like you would normally, then set the $UpdatesPath variable above to the SMS package location.
Exactly how are you keeping track of wich patches to add to a certain wim-file? Right now, I tried to add 105 patches, "only 87" of them where applied, while some failed. Keeping track of which failed on how to correct it, seems like an impossible task. Any tips? :)
Change \Mount-Wim to /Mount-Wim
Nice catch Vladimir!
is there a way to get a verbose output so that we can see all the updates installed.
I see this is done through Powershell, Is this simply a batch file ran through Powershell?
Yep, just wrapping the dism commands in PowerShell. You could use any language to perform the loop.
Nice script! thanks
Just wanted to thank you for this!
My reading of this article led me to believe that I should supply my downloaded patches as-is, in their *.msu file form. This turned out not to be the case. My attempts to apply the patches in this form repeatedly failed. Upon further research, it seems that the *.msu files need to be extracted and the *.cab files resulting from the extraction are what should be supplied to this script. If this is true as it seems to be, then this important detail should probably be supplied in this article. It could save hours of frustration from trying to apply *.msus. Also, under "Automating the installation", there is still a \mount-wim that should be /mount-wim. While it does make people stop and read what the script is actually doing, it might be worth correcting this.Thanks for the write-up!
Hello,It must have been my lucky day as far as DISM goes. My guess is I either used ti wrong index #, or installed some particular update that had to be installed in order to show all updates, really don't have an idea.After I used the updated wim file 151 updates were shown compared to the original wim file that showed 109. I downloaded a fair amount of the updates, & after the installation w/ the new wim, 82 updates were shown to be left to do, which tells me the updated wim is doing as should.I know there's an expand command to use to export or whatever the better word may be. I'm trying to convert the IE 11.exe to a MSU file, but doesn't seem the expand command will do that.Thanks a lot because I can now progress further as far as integrating .msu w/ DISM
Ive just used this script to add 40+ MSU files to a wim file and it worked great, saved me so much time. Should this work the same for .CAB files as I get the following error
An error occurred trying to open - I:\IT Shared Area\Software\Windows Updates\Office 2010\all-acsrvwfe-x-none_a5c4ba0d958241ff2cce9fbad35e4ccef8641
81d.cab Error: 0x80070002
The system cannot find the file specified.