Back to Resources

Level Verified

Windows Create Restore Point Script

Created by

Level

Type

Script

Category

Maintenance

Platforms
WindowsApple iOSLinux

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.

Description

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.

Script

1<#
2This resource is provided as a convenience for Level users. We cannot 
3guarantee it will work in all environments. Please test before deploying 
4to your production environment. We welcome contributions to our community 
5library
6
7Level Library
8https://level.io/library/script-windows-create-restore-point
9#>
10
11# Define the restore point name
12$restorePointName = "{{RestorePointName}} - " + (Get-Date -Format "yyyy-MM-dd HH:mm:ss")
13
14# Function to check and enable System Restore
15function Enable-SystemRestore {
16    $restoreEnabled = Get-ComputerRestorePoint -ErrorAction SilentlyContinue
17    if (-not $restoreEnabled) {
18        Write-Host "Enabling System Restore on C: drive..."
19        Enable-ComputerRestore -Drive "C:\"
20    }
21}
22
23# Function to check and start Volume Shadow Copy Service (VSS)
24function Start-VSSService {
25    $vssService = Get-Service -Name "VSS" -ErrorAction SilentlyContinue
26    if ($vssService -and $vssService.Status -ne "Running") {
27        Write-Host "Starting Volume Shadow Copy Service..."
28        Start-Service -Name "VSS"
29    }
30}
31
32# Function to modify restore point frequency limit
33function Modify-RestoreFrequency {
34    $restoreFreqPath = "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\SystemRestore"
35    $restoreFreqKey = "SystemRestorePointCreationFrequency"
36    
37    $currentValue = (Get-ItemProperty -Path $restoreFreqPath -Name $restoreFreqKey -ErrorAction SilentlyContinue).$restoreFreqKey
38    if ($currentValue -ne 0) {
39        Write-Host "Adjusting restore point frequency limit..."
40        Set-ItemProperty -Path $restoreFreqPath -Name $restoreFreqKey -Value 0
41    }
42}
43
44# Run the checks and adjustments
45Enable-SystemRestore
46Start-VSSService
47Modify-RestoreFrequency
48
49# Attempt to create the restore point
50try {
51    Checkpoint-Computer -Description $restorePointName -RestorePointType 'MODIFY_SETTINGS' -ErrorAction Stop
52    Write-Host "System Restore Point created successfully with name: $restorePointName"
53    exit 0
54}
55catch {
56    Write-Host "ERROR: Failed to create System Restore Point. Details: $_"
57    exit 1
58}
59

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.

FAQ

  • 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.

Included with this Script:

Below is a list of what you can expect to find when importing this Script.

Script details:

The following data and settings will be imported with your script.

Script Name

Windows - Create Restore Point

Description

This PowerShell script creates a system restore point with a dynamic name that combines a custom field {{RestorePointName}} with the current timestamp in "yyyy-MM-dd HH:mm:ss" format. The script attempts to create the restore point using the Checkpoint-Computer cmdlet with the type 'MODIFY_SETTINGS', and then provides feedback by writing to the console whether the operation was successful (exiting with code 0) or failed (exiting with code 1).

Language

PowerShell

Timeout (In Seconds)

100

Run As

Local system

Import into Level

Related resources

Explore more automations, scripts, and policies to further enhance your IT operations.

View all resources