1 min read

Backup-DevSettings

Backup-DevSettings Code

<a href='/?search=%23Requires' class='obsidian-tag'>#Requires</a> -RunAsAdministrator
$BackupDir = "$HOME\Desktop\RegistryBackups"
if (-not (Test-Path $BackupDir)) { New-Item -Path $BackupDir -ItemType Directory | Out-Null }

$Timestamp = Get-Date -Format "yyyyMMdd_HHmmss"

Write-Host "--- Backing up Critical Registry Keys ---" -ForegroundColor Cyan

# Define the paths we are modifying in our other scripts
$KeysToBackUp = @(
    "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock",
    "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem"
)

# Use the native reg.exe export tool
foreach ($Key in $KeysToBackUp) {
    # Extract the last part of the key name for the filename (e.g., "FileSystem")
    $FileName = $Key.Split('\')[-1]
    Write-Host "  Backing up: $Key" -ForegroundColor Gray

    # Exporting each key to its own unique .reg file
    reg export $Key "$BackupDir\$($FileName)_$Timestamp.reg" /y | Out-Null
}

Write-Host "`n[SUCCESS] Backups saved to: $BackupDir" -ForegroundColor Green
Write-Host "To restore, simply double-click the .reg files in that folder." -ForegroundColor Yellow

# Optional: Opens the folder so you can verify the files exist
Invoke-Item $BackupDir