Use PowerShell to Patch VHD and WIM Image Files

Ron

Microsoft PFE Ben Pearce shows how to use Windows PowerShell to perform offline servicing of Virtual Disks (VHD) and Windows Imaging Format (WIM) files.

This post discusses the ServiceImage.ps1 script that is located on the Scripting Guys Script Repository.  This script injects patches to an offline .vhd or .wim file. It is a really useful script and also shows nicely how to wrap regular command line tools in Windows PowerShell. Hopefully this post will help you do the following tasks.

  1. Understand the high level flow of the script
  2. Use Deployment Image Servicing and Management (DISM) and DiskPart command lines
  3. Generate command lines at run time
  4. Run command lines within Windows PowerShell