Integrate /ResetBase and WIM Optimization/Exporting into Offline Servicing
In the interest in making my OS deployment task sequences as fast and as optimized as possible, I always optimize WIM files anytime they're updated or re-created.
In my build/capture task sequence, I add a step at the very end before capture to run DISM /StartComponentCleanup /ResetBase so that all of the superseded updates are removed from the base image before it is captured. This results in a smaller WIM file and obviously, faster deployment times.
With the built-in Offline Servicing option for OS images, once new updates are added, they remain in the component store of the image when the image is unmounted, and also, all of the deleted/superseded files still remain inside the [DELETED] folder in the root of the WIM database because the image is not exported once it is updated by Configuration Manager so the WIM file continues to grow larger and larger every time it is updated using Offline Servicing.
Presently, I have a script I've created, 'Optimize-WIMFile.ps1', that I run against the WIM file source after it is updated via Offline Servicing that does the following:
- Mounts the specified OS WIM
- Runs 'DISM /Image:Mount /StartComponentCleanup /ResetBase' if
the image supports it (i.e. OS version greater than Windows 7)
- Unmounts the WIM
- Exports the WIM file to remove all deleted or replaced data using
DISM module's Export-WindowsImage
Since Offline Servicing is already mounting the WIM for you on the server when updating it, there should be an option (a simple checkbox would suffice) to "Remove superseded updates" after the image is updated that essentially runs DISM /ResetBase against the WIM while it is still mounted before unmounting it.
After the WIM is updated and unmounted, it should then be exported to clean up the removed data - I'm not sure why this is not already a default. The WIM file will only grow in size with all of the old deleted junk every time you update it if it is not exported. You could even make an option for this as well with a drop-down menu that lets you choose the compression level on the WIM when exporting to the final image.
I've tried to automate this process completely by making a script that triggers the OfflineServicing schedule on all of my OS images in Configuration Manager and then calls my Optimize-WIMFile script, but the problem is that I can't find any way to track status of the offline servicing on each image to know when it's safe to begin optimizing the WIM, as Get-CMOperatingSystemImageUpdateSchedule is not returning anything when the schedule is created to run immediately so I have to wait for all of the servicing to complete, and then manually run the optimizations.
This would make sooo much more sense to have built-in to the OfflineServicing since it's literally two simple commands run against the WIM. Please take it into consideration!
Thanks for all your suggestions and feedback, updating status to completed.
SCCM 1902 fast Ring released today
@Garrett Marsh By the way, do you need the script for optimizing WIM files, or the one I made to invoke the offline servicing on all of my imported images?
@Bob Mac Neill Right on Bob!
Your team is fantastic. From the documentation it sounds almost 100% made-to-order. I look forward to trying it out. I'll give it a go soon.
@Garrett Marsh I apologise for missing your comment. I haven't gotten notifications for replies until today's update. I'll try and remember to upload it for you in the morning.
Garrett Marsh commented
@Taylor do you have your script on GitHub, or Gallery? Would like to leverage it.
L U commented
Also would the optimizations clean up this problem (see link below), does it also need to be examined more deeply? https://configurationmanager.uservoice.com/forums/300492-ideas/suggestions/34860946-fix-offline-servicing-so-it-doesn-t-show-unapplica
L U commented
Could offer an option in the built-in servicing set-up to call a command, package or task sequence to run other things while mounted, as well as adding all the optimizations mentioned as direct options in the console, perhaps On by default?
Frank Trout commented
My apologies for not going into more detail. Yes, the feature is there but quite a few people have issues with the size of the WIM after the servicing, especially in environments with low bandwidth. There are quite a few scripts out there to "optimize" offline servicing so that it can be as lean as possible and it would be nice to include these maintenance steps in the ConfigMgr console.
Frank Trout commented
It would be great to have an offline servicing option for OS Upgrade Packages to inject the latest dynamic updates, patches, etc.
Greg Nottage commented
I support this UV request.
I’ve been very impressed with the community developed scripts that handle offline media servicing, but I think some of this functionality should be native to ConfigMgr. I would like the CM dev team to improve the current offline servicing capabilities to include features like – automatically install servicing stack updates (should any be required), automatically shrink the deployment WIM after it has been serviced offline, enable features (like .NET v3.5 etc.) – think the old MDT ‘Install Roles and Features’ selector page.
I believe this would truly remove the requirement to have a build and capture process, and is what we should expect from a Modern Management platform.