[CmdletBinding()] param( [string]$OutDir, [string[]]$Keys ) $ErrorActionPreference = 'Stop' if (-not $Keys) { $Keys = @( 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', 'HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall', 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run', 'HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run', 'HKLM\SYSTEM\CurrentControlSet\Services', 'HKLM\SOFTWARE\Policies\Microsoft', 'HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer' ) } if (-not $OutDir) { $OutDir = Join-Path (Get-Location) ('registry-backup-' + (Get-Date -Format 'yyyyMMdd-HHmmss')) } $OutDir = [IO.Path]::GetFullPath($OutDir) if (-not (Test-Path -LiteralPath $OutDir -PathType Container)) { New-Item -ItemType Directory -Path $OutDir | Out-Null } $ok = 0 $failed = 0 foreach ($key in $Keys) { $safeName = ($key -replace '[:\\]', '_') $file = Join-Path $OutDir ($safeName + '.reg') & reg.exe export $key $file /y 2>&1 | Out-Null if ($LASTEXITCODE -eq 0 -and (Test-Path -LiteralPath $file)) { $ok++ Write-Host "Экспортировано: $key" } else { $failed++ Write-Warning "Не удалось экспортировать: $key" } } Write-Host "Готово. Успешно: $ok, с ошибками: $failed" Write-Host "Папка: $OutDir" Write-Host 'Реестр не изменялся, выполнялся только экспорт.'