Hi All,
We’ve recently started using MDT 2013 Update 1 and we’ve noticed some of the scripts that worked seamlessly in 2012 have started producing errors. We use the DISM PowerShell cmdlets to verify the consistency of WIM files post backup. If the cmdlet fails to verify the WIM file the build bombs out to prevent data loss.
Here’s the error we’ve been seeing:
The ‘Get-WindowsImage’ command was found in the module ‘Dism’, but the module could not be loaded. For more information, run ‘Import-Module Dism’
Googling has found the following workarounds:
Enable Loading from remote sources – This didn’t work reliably for us.
Replace corrupt Dism dll with a working one – This method worked for us but I’d like to expand on it.
Thanks to the guys at DeploymentPros we were able to overcome this problem. What ended up working best for us was a Powershell script that deleted the corrupt dll and copied down a fresh one from the deployment share.
We found the DISM dll included in the Assessment and Deployment Kit located here: C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\x86\DISM\Microsoft.Dism.Powershell.dll and copied it to our Scripts folder inside our deployment share. Then added a step to the task sequence to run the PowerShell script.
Here’s the guts of the script, nothing much to it:
1 2 3 4 |
$TSEnv = New-Object -ComObject Microsoft.SMS.TSEnvironment Remove-Item $LocalLocation -Force -ErrorAction Stop Start-sleep 1 Copy-Item $RemoteLocation $LocalLocation -Force -ErrorAction Stop |
However we’ve added quite a bit of logging in our final script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
$TSEnv = New-Object -ComObject Microsoft.SMS.TSEnvironment Write-Host "DISM Workaround Started..." $RemoteLocation = $TSEnv.Value("DeployRoot") + "\Scripts\Microsoft.Dism.PowerShell.dll" $LocalLocation = "$ENV:SystemRoot\System32\WindowsPowershell\v1.0\modules\dism\Microsoft.Dism.PowerShell.dll" $ErrorLevel = 0 Try { Write-Host "Attempting to remove $LocalLocation" Remove-Item $LocalLocation -Force -ErrorAction Stop Start-sleep 1 If(Test-Path $LocalLocation) { Write-Host "Failed to remove $LocalLocation!" } Else { Write-Host "Succesfully removed $LocalLocation!" } } Catch { $ErrorLevel = 1 Write-Host "Couldnt remove $LocalLocation! The error was:" Write-Host $Error[0].Exception } Try { Write-Host "Attempting to Copy $RemoteLocation to $LocalLocation" Copy-Item $RemoteLocation $LocalLocation -Force -ErrorAction Stop If(Test-Path $LocalLocation) { Write-Host "Succesfully copied $RemoteLocation to $LocalLocation!" } Else { Write-Host "Failed to copy $RemoteLocation to $LocalLocation!" } } Catch { $ErrorLevel = 1 Write-Host "Couldnt copy $RemoteLocation to $LocalLocation! The error was:" Write-Host $Error[0].Exception } Write-Host "DISM Workaround finished with return code $ErrorLevel" Exit $ErrorLevel |
Please let us know if this worked for you, or if you’ve found any alternative solutions!
Cheers, John.