mirror of
https://github.com/NexusOne23/noid-privacy.git
synced 2026-02-13 06:54:28 +01:00
71 lines
2.3 KiB
PowerShell
71 lines
2.3 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Restore Microsoft Edge policy settings from backup
|
|
|
|
.DESCRIPTION
|
|
Restores Edge policies from a previous backup.
|
|
Integrates with Core Rollback system or standalone .reg file.
|
|
|
|
.PARAMETER BackupPath
|
|
Path to backup file or backup ID (for Core Rollback system)
|
|
|
|
.OUTPUTS
|
|
PSCustomObject with restore status
|
|
|
|
.NOTES
|
|
Restores: HKLM:\Software\Policies\Microsoft\Edge
|
|
#>
|
|
|
|
function Restore-EdgePolicies {
|
|
[CmdletBinding()]
|
|
param(
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$BackupPath
|
|
)
|
|
|
|
$result = [PSCustomObject]@{
|
|
Success = $false
|
|
KeysRestored = 0
|
|
Errors = @()
|
|
}
|
|
|
|
try {
|
|
Write-Log -Level DEBUG -Message "Restoring Edge policy settings from: $BackupPath" -Module "EdgeHardening"
|
|
|
|
# Check if it's a .reg file (standalone backup)
|
|
if ($BackupPath -like "*.reg" -and (Test-Path $BackupPath)) {
|
|
Write-Log -Level DEBUG -Message "Restoring from .reg file..." -Module "EdgeHardening"
|
|
|
|
# Import using reg.exe (built-in)
|
|
$process = Start-Process -FilePath "reg.exe" `
|
|
-ArgumentList "import `"$BackupPath`"" `
|
|
-Wait `
|
|
-NoNewWindow `
|
|
-PassThru
|
|
|
|
if ($process.ExitCode -eq 0) {
|
|
$result.Success = $true
|
|
$result.KeysRestored = 1
|
|
Write-Log -Level DEBUG -Message "Standalone backup restored successfully" -Module "EdgeHardening"
|
|
}
|
|
else {
|
|
$result.Errors += "reg.exe import failed with exit code: $($process.ExitCode)"
|
|
}
|
|
}
|
|
else {
|
|
# Try Core Rollback system
|
|
Write-Warning "Restore from Core Rollback system not yet fully implemented"
|
|
Write-Warning "Please use Framework's Invoke-Rollback for full restore"
|
|
|
|
# Placeholder for future integration
|
|
$result.Errors += "Please use Invoke-Rollback from Framework for integrated restore"
|
|
}
|
|
|
|
}
|
|
catch {
|
|
$result.Errors += "Restore failed: $($_.Exception.Message)"
|
|
Write-Log -Level DEBUG -Message "Restore failed: $_" -Module "EdgeHardening"
|
|
}
|
|
|
|
return $result
|
|
}
|