Tutorials

How to Unmount or Discard failed WIMs in bulk on a Windows system

How to Unmount or Discard failed WIMs in bulk on a Windows system

WIM or Windows Image is a file-based disk image format that was developed by Microsoft to deploy Windows.  To understand it better, ISO or VHD are sector-based formats, while WIM is a file-based format for a disk. If you are implementing a lot of WIM files on multiple computers, and some of them fail, here is how to bulk dismount or discard failed WIMs.

The reason why WIM is useful is that its hardware-independent, you can make them bootable using WIMBoot. Since Windows bootloader supports booting Windows from within a WIM file, it becomes easier to deploy.

How to Unmount or Discard a failed WIM

There are three ways to dismount or discard failed WIMs in bulk on a Windows system:

  1. PowerShell Registry path method
  2. Using Dismount-WindowsImage method
  3. Windows PowerShell 7 Parallel method

You can use any of these methods, but the last one works with PowerShell 7 only.

1] Powershell Registry path method

Adam Gross, a Microsoft MVP, posted this method. You can use this method to find the location of all mounted images,  extract the discard status, and then dismount each of them.

Get-ChildItem -Path "HKLM:\SOFTWARE\Microsoft\WIMMount\Mounted Images" | Get-ItemProperty | Select -ExpandProperty "Mount Path" | ForEach-Object Dismount-WindowsImage -Path $_ -Discard

However, this will bulk dismount discard failed WIMs one by one in sequence and takes around 25 seconds each.

2] Dismount-WindowsImage method

It is a PowerShell command which can be used to discard or save changes to a Windows image, and then dismount it. So it's not just about failed ones, but also works for all. The best part is that it can save the state if you are planning to unmount a WIM temporarily.

To Discard and dismount

Dismount-WindowsImage -Path  [-Discard] [-LogPath ] [-ScratchDirectory ] [-LogLevel ] []

To Save and Dismount

Dismount-WindowsImage -Path  [-Save] [-CheckIntegrity] [-Append] [-LogPath ] [-ScratchDirectory ] [-LogLevel ] [] 

Sample Command

Dismount-WindowsImage -Path "c:\offline" -Discard

So the final command will now look like (Thanks Manel) -

Get-WindowsImage -Mounted | ForEach Measure-Command Dismount-WindowsImage -Discard -Path $_.Path

3] Bulk dismount discard failed WIMs using Windows PowerShell 7 Parallel method

It is available in preview and will be available with PowerShell 7.  According to Merlin, this new method dismounted three images in just under 10 seconds instead of almost 25 seconds when ran in sequence.

Get-WindowsImage -Mounted | foreach -Parallel Measure-Command Dismount-WindowsImage -Discard -Path $_.Path

These are some of the best methods you can use to bulk dismount or discard failed WIMs in one go.

While unmounting one doesn't take much time, but this can be huge for Enterprise deployment. The parallel switch is going to be a life savior for many, as it is fifty percent faster compared to the sequential method.

Suosituimmat Oculus App Lab -pelit
Jos olet Oculus-kuulokemikrofonin omistaja, sinun täytyy olla tietoinen sivulatauksesta. Sivulataus on prosessi, jolla ei-kaupallista sisältöä asennet...
Top 10 Games to Play on Ubuntu
Windows platform has been one of the dominating platforms for gaming because of the huge percentage of games that are developing today to natively sup...
5 parasta arcade-peliä Linuxille
Nykyään tietokoneet ovat vakavia koneita, joita käytetään pelaamiseen. Jos et pääse uusiin korkeisiin pisteisiin, tiedät mitä tarkoitan. Tässä viestis...