# RESTORE script generated by lot6_archive_apply_v1.5.9.ps1 param([switch]$Preview,[switch]$Execute) if(-not $Execute -and -not $Preview){ $Preview=$true } if($Preview -and $Execute){ Write-Host '[NOK] Choose -Preview OR -Execute'; exit 2 } $map = Join-Path $PSScriptRoot 'RESTORE_MAP.txt' if(!(Test-Path -LiteralPath $map)){ Write-Host ('[NOK] Map not found: ' + $map); exit 3 } $lines = Get-Content -LiteralPath $map -ErrorAction SilentlyContinue $i=0; $ok=0; $ko=0 foreach($ln in $lines){ if([string]::IsNullOrWhiteSpace($ln)){ continue } $parts = $ln.Split('|',2) if($parts.Count -lt 2){ continue } $dst = $parts[0]; $src = $parts[1] $i = $i + 1 if($Preview){ Write-Host ('[' + $i + '] ' + '$dst=' + $dst + ' -> $src=' + $src); continue } try{ $dir = [IO.Path]::GetDirectoryName($src) if($dir -and -not (Test-Path -LiteralPath $dir)){ [System.IO.Directory]::CreateDirectory($dir) | Out-Null } Copy-Item -LiteralPath $dst -Destination $src -Force $ok = $ok + 1 } catch { Write-Host ('[NOK] ' + $_.Exception.Message); $ko = $ko + 1 } } if(-not $Preview){ Write-Host ('[OK] Restore done. OK=' + $ok + ' NOK=' + $ko) } else { Write-Host '[OK] Restore preview complete.' }