ScriptMaintenanceWindows

Create a Windows restore point

Create a named System Restore point with a timestamp.

See what you’re importing.

Read-only preview

PowerShell Timeout 100s Runs as Local system
<#
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
}

Before you run it.

  1. Schedule via Level Automations

    Run this script before patching cycles, software updates, or security audits.

  2. Test before deployment

    Run manually on a test machine to confirm proper restore point creation.

  3. Ensure System Restore is enabled

    This script relies on Windows’ System Restore feature being active.

  4. Name consistency

    Use clear, structured naming conventions to identify restore points easily.

More about this resource.

What it does

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.

When to use it
  • 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.
The problem it solves

System changes, such as 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.

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.