$ErrorActionPreference = 'Continue' $d = 'C:\PF\TEST_i' $src = Join-Path $d 'PF.esd' $dst = Join-Path $d 'Data.wim' $log = Join-Path $d 'wim-build.log' $done = Join-Path $d 'wim-done.txt' Remove-Item $done -Force -ErrorAction SilentlyContinue if (Test-Path $dst) { Remove-Item $dst -Force -ErrorAction SilentlyContinue } "=== start $(Get-Date -Format 'HH:mm:ss')" | Out-File $log -Encoding UTF8 foreach ($i in 1, 2, 3) { "--- index $i" | Out-File $log -Append -Encoding UTF8 & dism.exe /Export-Image /SourceImageFile:"$src" /SourceIndex:$i /DestinationImageFile:"$dst" /Compress:none 2>&1 | Out-File $log -Append -Encoding UTF8 } "=== end $(Get-Date -Format 'HH:mm:ss')" | Out-File $log -Append -Encoding UTF8 if (Test-Path $dst) { $len = (Get-Item $dst).Length "OK $len" | Out-File $done -Encoding UTF8 } else { "FAIL" | Out-File $done -Encoding UTF8 }