Properly handle restore point creation in custom mode when using -Silent parameter and system restore is disabled

This commit is contained in:
Raphire
2025-05-05 23:46:45 +02:00
parent 09b4eb7f6b
commit 8def22ac48

View File

@@ -748,19 +748,17 @@ function CreateSystemRestorePoint {
$SysRestore = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore" -Name "RPSessionInterval"
if ($SysRestore.RPSessionInterval -eq 0) {
if (-not $Silent) {
if ($( Read-Host -Prompt "System restore is disabled, would you like to enable it and create a restore point? (y/n)") -eq 'y') {
try {
Enable-ComputerRestore -Drive "$env:SystemDrive"
} catch {
Write-Host "Error: Failed to enable System Restore: $_" -ForegroundColor Red
Write-Output ""
return
}
} else {
if ($Silent -or $( Read-Host -Prompt "System restore is disabled, would you like to enable it and create a restore point? (y/n)") -eq 'y') {
try {
Enable-ComputerRestore -Drive "$env:SystemDrive"
} catch {
Write-Host "Error: Failed to enable System Restore: $_" -ForegroundColor Red
Write-Output ""
return
}
} else {
Write-Output ""
return
}
}