30 lines
1.3 KiB
PowerShell
30 lines
1.3 KiB
PowerShell
$ErrorActionPreference = 'Continue'
|
|
$d = 'C:\PF\TEST_i'
|
|
$pf = Join-Path $d 'Data.pf'
|
|
$log = Join-Path $d 'pf-verify.log'
|
|
$done = Join-Path $d 'pf-verify-done.txt'
|
|
$base = 'C:\PF\USBInstaller\test'
|
|
|
|
Remove-Item $done -Force -ErrorAction SilentlyContinue
|
|
"=== start $(Get-Date -Format 'HH:mm:ss')" | Out-File $log -Encoding UTF8
|
|
|
|
& dism.exe /Get-WimInfo /WimFile:"$pf" 2>&1 | Out-File $log -Append -Encoding UTF8
|
|
|
|
foreach ($i in 3, 2, 1) {
|
|
$dir = Join-Path $base "apply$i"
|
|
if (Test-Path $dir) { Remove-Item $dir -Recurse -Force -ErrorAction SilentlyContinue }
|
|
New-Item -ItemType Directory -Path $dir | Out-Null
|
|
"--- apply index $i" | Out-File $log -Append -Encoding UTF8
|
|
& dism.exe /Apply-Image /ImageFile:"$pf" /Index:$i /ApplyDir:"$dir" 2>&1 |
|
|
Select-String -Pattern 'Error|completed|%' |
|
|
Select-Object -Last 3 | ForEach-Object { $_.Line } | Out-File $log -Append -Encoding UTF8
|
|
|
|
$items = Get-ChildItem $dir -Recurse -File -Force -ErrorAction SilentlyContinue
|
|
$files = ($items | Measure-Object).Count
|
|
$bytes = ($items | Measure-Object Length -Sum).Sum
|
|
"index ${i}: files=$files bytes=$bytes" | Out-File $log -Append -Encoding UTF8
|
|
Remove-Item $dir -Recurse -Force -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
"=== end $(Get-Date -Format 'HH:mm:ss')" | Out-File $log -Append -Encoding UTF8
|
|
"OK" | Out-File $done -Encoding UTF8 |