# Convert Data.wim -> PF.esd (LZMS / recovery compression), all three images. $ErrorActionPreference = 'Continue' $dir = 'C:\PF\TEST_i' $src = Join-Path $dir 'Data.wim' $dst = Join-Path $dir 'PF.esd' $log = Join-Path $dir 'esd-build.log' function W($s) { $s | Add-Content -Path $log -Encoding UTF8 } "=== start $(Get-Date -Format 'HH:mm:ss') ===" | Set-Content $log -Encoding UTF8 W ("source: " + $src + " " + [math]::Round((Get-Item $src).Length/1GB,2) + " GB") if (Test-Path $dst) { Remove-Item $dst -Force } $t = Get-Date $o1 = & dism.exe /English /Export-Image /SourceImageFile:$src /SourceIndex:1 /DestinationImageFile:$dst /Compress:recovery /CheckIntegrity 2>&1 $c1 = $LASTEXITCODE W ("index 1: code " + $c1 + " " + (((Get-Date)-$t).ToString('mm\:ss'))) $o1 | Select-Object -Last 3 | ForEach-Object { W (' ' + $_) } $t = Get-Date $o2 = & dism.exe /English /Export-Image /SourceImageFile:$src /SourceIndex:2 /DestinationImageFile:$dst /CheckIntegrity 2>&1 $c2 = $LASTEXITCODE W ("index 2: code " + $c2 + " " + (((Get-Date)-$t).ToString('mm\:ss'))) $o2 | Select-Object -Last 3 | ForEach-Object { W (' ' + $_) } $t = Get-Date $o3 = & dism.exe /English /Export-Image /SourceImageFile:$src /SourceIndex:3 /DestinationImageFile:$dst /CheckIntegrity 2>&1 $c3 = $LASTEXITCODE W ("index 3: code " + $c3 + " " + (((Get-Date)-$t).ToString('mm\:ss'))) $o3 | Select-Object -Last 3 | ForEach-Object { W (' ' + $_) } if (Test-Path $dst) { W ("result: " + [math]::Round((Get-Item $dst).Length/1GB,2) + " GB") $info = & dism.exe /English /Get-WimInfo /WimFile:$dst 2>&1 $info | Out-File (Join-Path $dir 'esd-info.txt') -Encoding UTF8 foreach ($l in $info) { if ($l -match 'Index :|Name :|Size :|Compression') { W (' ' + $l.Trim()) } } } else { W "result: FILE NOT CREATED" } W ("=== end $(Get-Date -Format 'HH:mm:ss') ===")