Automating Windows 10 Servicing
[6-Jul-2018: Updated Script to v 1.2 – New .NET 3.5.1 install command (per Mike Horton @mikeh36)]
After attending MMS one of the items that I put on my “Post-MMS To Do” list was to patch my OS Upgrade package source the proper way. I don’t want to do it manually, nobody does, so I set out to learn exactly how to do it right and script it.
That where Mike Terrill and Johan Arwidmark come in.
Mike wrote a very detailed blog about not only how to update the source WIM but more importantly, why you should do it that way. So from that, I learned what I needed to do. The next step was to script it. As I was starting to write my script Johan posted a script that does precisely that. So, credit where credit is due. I want to thank the two of them for getting me started. Hopefully, they’ll approve of what I’ve created.
First things first though. Here you can find the blogs of Mike and Johan that I used to get started with.
So what did I do?
I used Johan’s script as my foundation (aka “Stealing with Pride“). I wanted to make it flexible, so I started by doing away with the hard-coded references in updates and folder locations. In place of that, I also tried to make the script “smart” enough to pull the proper updates in the folders, but I’ll get into that shortly. I then wanted to make it simple to use the same script to update an 1803 WIM (or a 1809.1903/1909/2003/etc WIM for that matter).
First, you’re going to want to download a copy of my script from GitHub.
Next, you’ll create the needed folder structure. Start with a folder at the root of a drive. It doesn’t necessarily have to be in the root but it’s just simpler that way. The script will orient itself to that folder and reference everything from there. The name of the folder is unimportant and you’re free to choose any name you like. For my example, I’ve named the root folder “W10Servicing”
Inside that root folder, you’ll need to create some sub-folder trees. I’ll use 1709 as my example. For 1803, just replace the “1709” with “1803”.
Download from either MSDN or the Volume License site the ISO for Windows 10 Build 1709 and place it into this folder. You don’t have to rename the ISO, but feel free to if you’d prefer.
From the Microsoft Update Catalog site, download the latest security update for Adobe Flash and place it into this folder.
As of 29 Jun 2018 – KB4287903
Download the latest Cumulative Update for 1709 and place it into this folder.
As of 29 Jun 2018 – KB4284822
Download the latest Servicing Stack Update for 1709 and place it into this folder.
As of 29 Jun 2018 – KB4132650
In all three of these Updates folders, you can place the updates (the MSU files) into root or you can create sub-folders to keep them organized. If you place them into sub-folders you can freely name them anything you like. You can name them after the KB number or the release date, it does not matter. In my example, I used the posted name as the subfolder name. You can also store multiple versions of the updates. In the screenshot above I have the last 3 Cumulative Updates all kept in that same folder. The script will recursively search the appropriate sub-folder tree and select the MSU with the most recent creation date. This way you can continue to place updates into their folders and the script will sort them out and use the latest. You won’t have to edit the script and change any file references.
Last setup step, place a copy of my script into the root of your folder (at the same level as “ISOs” and “Updates”).
Running the Script
The script takes a Windows 10 build number as a command line parameter. As it stands today, if no build number is passed to the script it will default to Build 1709.
PS D:\W10Servicing> .\Update_W10_Install_WIM_v1.1.ps1 -BuildNum 1709
If you want to update Build 1803, just create the folder structure based on 1803 and populate it with the appropriate downloads for 1803. Same for 1809, 1903, etc.
How does it work and what does it do?
The bulk of the code is directly from Johan’s original script. I made two changes. The first was to add the command line parameter to pass the build number.
The second change was a function I added that would enumerate all of the files in a given path, find the newest and return the result. This way you can keep adding new updates as they are released and do not have to update the script.
The remainder of the code comes directly from Johan’s script. It will mount the ISO, extract the WIMs and update them.
Running the script will take some time. The CUs take a while to add to the WIMs, so you will probably fire off the script and come back to it later when it is done.
Okay, when it is all done you will have a few new folders.
Inside the “WIMs” folder you will find an updated install.wim and boot.wim.
Take the new, patched install.wim and replace the factory one in your OS Upgrade package. Mike Terrill’s blog explains the changes you need to make to your task sequence, etc..
Posted on June 29, 2018, in Configuration Manager, Handy to Have, MMS, OSD, PowerShell, SCCM, Task Sequences and tagged Configuration Manager, MMS, OSD, System Center Configuration Manager, Upgrade, Windows 10. Bookmark the permalink. 1 Comment.