Photo by Shubham Dhage on Unsplash

Photo by Shubham Dhage on Unsplash

PowerShell OSDBuilder module

Image Manager

Article from ADMIN 69/2022
By , By
The PowerShell OSDBuilder module is designed to help admins maintain their system images while enforcing security.

Many system administrators use images to provide customized Windows installations that comply with company policies and requirements, so images of Windows are an important tool to help them keep their systems up to date while enforcing security. The PowerShell OSDBuilder module is designed to help manage the overhead of maintaining these images.

Online vs. Offline

Administrators are always happy to argue about which is the "better way" to manage Windows images: online or offline; however, there is no one answer to this question. If you want to maintain your Windows images online, you first need to set up a Windows installation (usually on a virtual machine) that suits your needs and then grab an image of it, either with Microsoft tools or third-party software such as Baramundi. This image then needs to be started up again for retroactive updates and refreshed after applying the updates. One argument in favor of the offline method, on the other hand, is the possibility of including updates automatically to the Windows images. One disadvantage of this method is that it is not possible to include desktop applications in a Windows image.

Neither method delivers an unequivocal knock-out factor. The IT department needs to decide which approach is the best fit for their systems. The PowerShell OSDBuilder module (Figure 1) offers one potential approach to managing images offline, which you then distribute with System Center Configuration Manager (SCCM) or some other tool. One big advantage of OSDBuilder is that all information is stored in a response file, so the file contains everything you need to update the image in question.

Figure 1: The OSDBuilder module adds new cmdlets, displayed here with Get-Command.

Installing the OSDBuilder Module

We used a newish version of Windows 10 21H1 (build 19043.1320) running on a virtual machine on VMware Workstation 16 for this example. The PowerShell commands were tested in both version 5.1, which is found by default on Windows 10, and the current version 7.2; they have only a few differences, and we will point them out at the appropriate points in the article. Installing OSDBuilder is like installing any other module in PowerShell; just type the command:

Install module -Name OSDBuilder

The module must be installed from the PowerShell Gallery (PSGallery) repository [1]. Windows classifies this repository as untrusted by default. PowerShell version 5 and version 7 both draw your attention to this fact after you enter the commands for installation, and you are prompted to decide whether you really want to do this. Installation is possible immediately after confirming in version 7, whereas you need to download and install the matching NuGet manager first in version 5. NuGet is a package manager for .NET that helps developers create, share, and use .NET libraries. After completing this step, you can then install the OSDBuilder module. To avoid problems when executing scripts, the recommendation is to lift this restriction by running the next command on the system in question:

Set-Executionpolicy Bypass -force

The -force parameter is not absolutely necessary here, but it effectively prevents additional prompts from appearing.

Now download a current ISO file for Windows 10 21H1, version dated October 2021, from your Visual Studio account with Microsoft and double-click to mount it as drive F: on the virtualized system. Our test system has a partition size of approximately 100GB that is mapped as drive E:. We will be using this for OSDBuilder, which is why we need to assign the corresponding path to the module in the next step:

Get-OSDBuilder -SetPath E:\OSDBuilder

This command also specifies the target folder for the images to be created. The module now displays a mass of information on the screen. You will discover that the version of OSDBuilder you are using works with Windows 10 starting in version 1607 up to and including version 21H1 and that it supports Windows 11 version 21H2 and Windows Server starting with version 2016 1607 up to version 2022 21H1. Additionally, some shortcuts for further processing are listed, including the call

Get-OSDBuilder -CreatePaths

which creates a directory structure (Figure 2) to suit the previously specified path. Now that all the prep work is complete, it is time to select the medium to be installed.

Figure 2: Using PowerShell to create the directory structure in the target directory.

Importing and Maintaining the Image

The DVD images for Windows officially provided by Microsoft usually contain a whole series of images with the different editions of the operating system. Because the image was already mounted as a virtual drive on the filesystem, the command


at the PowerShell command line (Figure 3) scans the mounted DVD and lists its content; it also works if you have several disks mounted on your system.

Figure 3: If more than one Windows edition is found on the source DVD, OSDBuilder displays all of them and gives you a choice.

OSDBuilder now displays the entire content of the different DVDs, and you can select the desired edition in the listing window. We used Windows 10 Pro (image index number 5) for this test.

Next, you need to import the corresponding media into the designated directories. In the process, OSDBuilder outputs information about the imported Windows image (WIM) index while creating a text logfile in the logs directory. The next step is to update the selected Windows image:

Update-OSmedia -Download -Execute

You are then presented the selected image once again in a list, where you need to select it; the system then starts downloading the updates and integrating them into the image.

Finally, take a quick look at the tasks mentioned at the beginning. You can use these commands to initiate a build process and create media with your choice of updates:

    -TaskName <name of task>
    -EnableFeature <Feature to be enabled>

An example could look like:

New-OSBuildTask -TaskName "Install NetFx" -EnableFeature -EnableNetFx3

To run the build process for the selected image at the same time, change the command to:

New-OSBuild -Download -Execute -EnableNetFX -SelectUpdates

Pressing the -Download button downloads any missing updates directly from Microsoft and applies them to the image. The -Execute parameter triggers the build process directly, whereas -SelectUpdates brings up a window where you can choose from the available updates. If you run the call this way, the module prompts you for the name of the matching task. If you want this update to be "taskless," you need the command:

New-OSBuild -Download -Execute -EnableNetFX -SelectUpdates -Skiptask

After selecting the imported OS image, the module again provides a grid view with the updates from which to choose, including the service.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Use PowerShell to manage Exchange Online
    Exchange Online in Office 365 can be managed just like its local counterpart with similar, sometimes identical, PowerShell cmdlets.
  • The best cmdlets for PowerShell
    Windows is no longer the system for mouse pushers. In the latest server version, the default installation installs without a GUI, and management via PowerShell is a part of everyday life for Windows administrators.
  • Top PowerShell Cmdlets

    Windows is no longer the system for mouse pushers. In the latest server version, the default installation installs without a GUI, and management via PowerShell is a part of everyday life for Windows administrators.

  • Convert Linux shell commands into PowerShell cmdlets
    Convert Linux shell commands into PowerShell cmdlets and modules and run them in a PowerShell environment.
  • Innovations in PowerShell 5
    Windows 10 brings an updated, fifth release of PowerShell that vastly simplifies the task of managing modules and software packages. The scripting language now also handles various formatted output from commands and selection lists.
comments powered by Disqus
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs

Support Our Work

ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.

Learn More”>


		<div class=