microsoft / MSLab

Azure Stack HCI, Windows 10 and Windows Server rapid lab deployment scripts
MIT License
1.17k stars 280 forks source link

Add try catch for stale / mounted WindowsImages #565

Open Karl-WE opened 9 months ago

Karl-WE commented 9 months ago

In some cases deploy.ps1 or other scripts may fail because of an incorrectly mounted / dismounted or stale image.

This could be achieved before mounting a new image with Mount-WindowsImage, to check the condition

get-windowsimage -mounted is not $null

then execute

dism /cleanup-mountpoints