Properly catch errors when creating system restore point #231

This commit is contained in:
Raphire
2025-05-04 22:35:58 +02:00
parent 0e3e0e1a02
commit d294eb6b7a

View File

@@ -756,8 +756,14 @@ function CreateSystemRestorePoint {
} }
if ($recentRestorePoints.Count -eq 0) { if ($recentRestorePoints.Count -eq 0) {
Checkpoint-Computer -Description "Restore point created by Win11Debloat" -RestorePointType "MODIFY_SETTINGS"
Write-Output "System restore point created successfully" try {
Checkpoint-Computer -Description "Restore point created by Win11Debloat" -RestorePointType "MODIFY_SETTINGS"
Write-Output "System restore point created successfully"
} catch {
Write-Host "Error: Unable to create restore point: $_" -ForegroundColor Red
return
}
} }
else { else {
Write-Host "A recent restore point already exists, no new restore point was created." -ForegroundColor Yellow Write-Host "A recent restore point already exists, no new restore point was created." -ForegroundColor Yellow