Shared Script Library
GitHubLinkedInSponsor
  • Overview
  • Software
    • Installers
      • Bluebeam Revu
      • Browser Extension
      • Google Chrome
      • Microsoft Defender for Endpoint
      • Microsoft Office
      • Microsoft Teams
      • QuickBooks Desktop
    • Uninstallers
      • Browser Extension
  • Device Management
    • Backups
      • SQL Databases
      • Synology Active Backup
      • Windows Restore Point
    • Updates
      • Dell Command Update
      • Microsoft Office
      • Microsoft Store Applications
      • Windows Management Framework
      • Windows Updates
    • Misc
      • Reset Local Group Policy
Powered by GitBook
On this page
  • Overview
  • Script
  • Examples
  • Example 1
  • Example 2
  • Parameters

Was this helpful?

  1. Device Management
  2. Backups

Windows Restore Point

PowerShell script to silently create a System Restore Point of the system drive.

PreviousSynology Active BackupNextUpdates

Last updated 1 year ago

Was this helpful?

Overview

Dev Insight: As of Windows 8, the default settings will not allow the creation of more than one system restore point in 24 hours. This script works around this limitation by temporarily modifying this setting.

This script can be used to automate the creation of System Restore Points on client machines, or to create a one-off checkpoint before applying changes to a machine.

Prerequisites: This script has no prerequisites.


Script

Examples

Example 1

.\CreateRestorePoint.ps1

This example creates a checkpoint with the default description of "Scripted Checkpoint".

Example 2

.\CreateRestorePoint.ps1 -Description 'Installed QuickBooks'

This example creates a restore point with the description "Installed QuickBooks".


Parameters

-Description

Optional string parameter that allows you to set a description for the restore point. If not provided, a default description of "Scripted Checkpoint" will be used.

https://github.com/wise-io/scripts/blob/main/scripts/CreateRestorePoint.ps1
<#
  .SYNOPSIS
    Creates a System Restore Point
  .DESCRIPTION
    Enables System Protection on all local drives and creates a System Restore Point.
  .EXAMPLE
    .\CreateRestorePoint.ps1 -Description 'Installed Quickbooks'
  .NOTES
    Author: Aaron Stevenson
#>

param (
  [string]$Description = 'Scripted Checkpoint'
) 

function Enable-SystemProtection {
  try {
    Enable-ComputerRestore -Drive $env:SystemDrive
    Write-Output "`nSystem Protection enabled for [$env:SystemDrive]"
  }
  catch { 
    Write-Warning "Unable to enable System Protection for [$env:SystemDrive]"
    Write-Warning $_
    exit 1
  }
}

function Start-SystemCheckpoint {
  $RegKey = 'HKLM:\Software\Microsoft\Windows NT\CurrentVersion\SystemRestore'
  $RegProperty = 'SystemRestorePointCreationFrequency'

  try {
    $RegValue = (Get-ItemProperty -Path $RegKey -Name $RegProperty -ErrorAction SilentlyContinue).$RegProperty
    Set-ItemProperty -Path $RegKey -Name $RegProperty -Value 0
    Checkpoint-Computer -Description $Description -RestorePointType MODIFY_SETTINGS
    if ($RegValue) { Set-ItemProperty -Path $RegKey -Name $RegProperty -Value $RegValue }
    else { Remove-ItemProperty -Path $RegKey -Name $RegProperty }
    Write-Output "Checkpoint created."
  }
  catch { 
    Write-Warning 'Unable to create checkpoint.'
    Write-Warning $_
    exit 1
  }
}

Enable-SystemProtection
Start-SystemCheckpoint