Level Verified

Windows Create Restore Point Script

Automatically create a Windows System Restore Point before or after critical actions. Ideal for scheduled automations, such as patching or security checks, ensuring a rollback option is available when needed.

Import into Level

Problem overview

System changes—like software updates, security modifications, or configuration adjustments—can sometimes lead to unintended issues. Having a reliable rollback option is essential for IT professionals and MSPs managing multiple endpoints. This script ensures a System Restore Point is created proactively, providing a safety net for reverting to a stable system state when necessary.

PowerShell 100s timeout Runs as Local system Windows
<#
This resource is provided as a convenience for Level users. We cannot 
guarantee it will work in all environments. Please test before deploying 
to your production environment. We welcome contributions to our community 
library

Level Library
https://level.io/library/script-windows-create-restore-point
#>

# Define the restore point name
$restorePointName = "{{RestorePointName}} - " + (Get-Date -Format "yyyy-MM-dd HH:mm:ss")

# Function to check and enable System Restore
function Enable-SystemRestore {
    $restoreEnabled = Get-ComputerRestorePoint -ErrorAction SilentlyContinue
    if (-not $restoreEnabled) {
        Write-Host "Enabling System Restore on C: drive..."
        Enable-ComputerRestore -Drive "C:\"
    }
}

# Function to check and start Volume Shadow Copy Service (VSS)
function Start-VSSService {
    $vssService = Get-Service -Name "VSS" -ErrorAction SilentlyContinue
    if ($vssService -and $vssService.Status -ne "Running") {
        Write-Host "Starting Volume Shadow Copy Service..."
        Start-Service -Name "VSS"
    }
}

# Function to modify restore point frequency limit
function Modify-RestoreFrequency {
    $restoreFreqPath = "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\SystemRestore"
    $restoreFreqKey = "SystemRestorePointCreationFrequency"
    
    $currentValue = (Get-ItemProperty -Path $restoreFreqPath -Name $restoreFreqKey -ErrorAction SilentlyContinue).$restoreFreqKey
    if ($currentValue -ne 0) {
        Write-Host "Adjusting restore point frequency limit..."
        Set-ItemProperty -Path $restoreFreqPath -Name $restoreFreqKey -Value 0
    }
}

# Run the checks and adjustments
Enable-SystemRestore
Start-VSSService
Modify-RestoreFrequency

# Attempt to create the restore point
try {
    Checkpoint-Computer -Description $restorePointName -RestorePointType 'MODIFY_SETTINGS' -ErrorAction Stop
    Write-Host "System Restore Point created successfully with name: $restorePointName"
    exit 0
}
catch {
    Write-Host "ERROR: Failed to create System Restore Point. Details: $_"
    exit 1
}

This PowerShell script generates a System Restore Point in Windows using the built-in Checkpoint-Computer command. The restore point is named dynamically with a timestamp for easy identification. When executed, it verifies if the restore point was successfully created, providing a confirmation message upon success or an error message if the operation fails.

Use cases

  • Automatically create restore points before patching via a Level Automation.
  • Generate restore points before modifying system configurations.
  • Implement scheduled restore points as part of a weekly security or maintenance task.
  • Run on-demand before deploying major application updates or drivers.

Recommendations

  • Schedule via Level Automations: Run this script before patching cycles, software updates, or security audits.
  • Test before deployment: Run manually on a test machine to confirm proper restore point creation.
  • Ensure System Restore is enabled: This script relies on Windows’ System Restore feature being active.
  • Name consistency: Use clear, structured naming conventions to identify restore points easily.

Frequently asked questions.

Why did the script fail to create a restore point?

Ensure System Restore is enabled on the target machine. Additionally, Windows limits restore point creation to once every 24 hours by default. Adjust registry settings to override this limit if needed.

Can I run this on Windows Server editions?

Some server versions have System Restore disabled by default. Enable it via Group Policy or registry settings before running this script.

How can I verify that a restore point was successfully created?

Use the vssadmin list shadows command or check the System Restore interface in Windows.

Can this be used for automated rollback?

System Restore must be manually triggered if needed. However, using this script in a proactive automation ensures a rollback option is always available.

Ready when you are.

No credit card. No sales call. Just sign up and start managing.