There are basically two ways to create a customized OS image. One option is to install the operating system in a VM, adapt it, generalize it with sysprep, and use DISM to capture it again as a WIM. The other option is offline servicing, where you mount install.wim, add or remove components, and save the changes.
GUI for offline servicing ^
For the offline method, Microsoft provides DISM as the standard tool; alternatively, the PowerShell module based on it can be used. With this tool, the user has to carry out all steps manually, from mounting the image to inserting drivers, updates, optional features and language packs, to the final dismount and commit. DISM, in particular, with its less intuitive syntax, makes this a complex task.
This is where Donna Ryan comes in with WIM Witch. It offers a GUI that covers all the above-mentioned aspects of image customization. The software is available as a PowerShell script and can be installed using PowerShellGet.
To do this, open a session with elevated privileges and enter the following command:
Install-Script -Name WIMWitch
As usual, the PowerShell Gallery is not accepted as a trustworthy repository, so you have to explicitly confirm the installation of the script again. Accordingly, you will find it under the following location:
Setting up the workspace ^
It is not intended that you use the script from the location mentioned above. Rather, you must first set up a directory as a workspace.
If you call WIMWitch.ps1 from the above-mentioned directory, the script will copy itself into the current directory by default. Alternatively, you can specify a different folder as the destination via a file dialog box.
Checking requirements ^
Now start the copy from the specified working directory. When it is first executed, the tool creates the workspace directory tree under which it will later store all the files it needs to customize the image. It then checks whether it is running in the newest version and offers to update itself if necessary.
In addition, WIM Witch checks whether the modules OSDUpdate and OSDSUS are installed in the most current version. They are needed to download Windows updates if you want to integrate them into the image.
Importing the standard image ^
The graphical user interface now appears, with a total of ten tabs. The first step is to import install.wim for Windows 10 or Server 2016/2019 that you want to customize.
The tool only accepts the ISO file of the installation media, which it mounts and then copies the Windows image from there to the folder imports\WIM. If required, you can also import the package for the .NET Framework from this source.
Next, select the imported file under the Source WIM tab. This opens a dialog box with a list of all editions of the OS that are included in install.wim. Select the one you want to deploy later.
Features on demand and language packs ^
From here on in, it is a matter of adding packages to the image or removing them. For example, you can load language packs and features on demand via the Import LP + FOD tab.
Here, too, WIM Witch copies the necessary files into the workspace and then opens a window based on Out-GridView within the Customizations tab, from which the required FoDs can be selected.
Integrating updates into the image ^
One common concern is to provide an image with the latest updates before deployment, so that the freshly installed computers are protected from the beginning. WIM Witch uses the PowerShell modules OSDUpdate and OSDSUS, mentioned above, for the download. They can be installed directly from the GUI under the Update Store tab.
After that, you can download the updates for the required version of the operating system. For this, the script uses the cmdlet Start-BitsTransfer. If you start up WIM Witch as a standard user in a session with administrative rights, it will fail with an error message that the user is not logged in. If you run the tool without extended rights, other problems will arise.
To avoid this problem, you should log on to Windows with a privileged account before you open a PowerShell window with elevated rights.
Alternatively, you could save your configuration under the Save/Load tab, restart the tool as a standard user, import the configuration you just saved, and then download the updates. Then switch back to the session with elevated privileges and reload the configuration.
If you want to insert drivers into the image, enter the paths to the respective files on the appropriate tab.
Removing apps ^
Another common requirement may be to remove the store apps supplied by Microsoft in the image. WIM Witch can also take on this task. For this purpose, it displays a list of all apps provided in install.wim under the corresponding tab. Select the ones you would like to get rid of.
Saving the configuration and starting the build ^
Once you have configured all customizations, you can generate the new image. However, if you need more images based on the same template in the future, you should save the configuration using Save/Load.
The build process can be started with the Make it So button, where you can enter a name for the target image before you trigger the command. By default, WIM Witch writes it to the CompletedWIMs folder.
After the customized image is successfully generated, it is recommended to clean up the directory tree under WIM Witch. There, you will not only find the imported install.wim, but the tool will also create a work copy of the WIM it under Staging. Each is larger than 4GB; in addition, there is the custom image with a similar size.