Service a Hyper-V .VHD / .VHDX Virtual Hard Disk Image Offline

The possibility of Servicing Offline a Virtual Hard Disk Image or a Windows Image is not something new. Actually, it’s a very handy way of adding or removing local packages, updates, drivers and Windows Features with minimal effort to your image. My story begins with my home lab, which I wanted to quickly install Updates and packages such as WMF 5.1 without using Windows Update to my Windows Virtual Machines that I use as Templates for Testing.

For that reason, I manage to compile the following PowerShell Script which will allow you to service offline a Windows .VHD/.VHDX virtual hard disk image. Grab the code below, save it to a PowerShell script and execute it directly from the Target Machine which the virtual hard disk image resides.

Some hints prior firing up the script

  • The Mount Folder must exist on the System, the script does not create the folder automatically.
  • The script will search all the underlying folders for packages in the folder that will be specified during the prompted questions.
  • It can also service a Windows Image File (.WIM) but with no option to select different indexes. For this operation, the script needs to be altered.

Some hints after firing up the script 🙂

  • In order to complete the installation of the packages, you need to boot the system that is using this Virtual Hard Disk File.
  • Packages that have dependencies other packages, will be skipped and not installed.
  • A log file is produced after execution. Can be found in the same folder were the Script Resides.
  • The script is intended to be used only for testing purposes and not for production servers.

The script has been tested and reported to be working with the following OS versions.

  • Windows 10 for desktop editions (Home, Pro, Enterprise, and Education)
  • Windows Server 2016
  • Windows 8.1
  • Windows 8
  • Windows Server 2012 R2
  • Windows Server 2012
  • Windows 7
  • Windows Server 2008 R2
  • Windows Server 2008 SP2

Thanks for reading!


George Markou

My Name is George Markou, IT Pro, Geek and Fancy Gadgets enthusiast. I am focused on Virtualization and Cloud Technologies.

%d bloggers like this: