Windows Powershell: Create System Restore checkpoint and invoke Volume Shadow Copy snap in one shot

Creating a System Restore checkpoint in Powershell is very easy, but why not customize it?

This has been tested on Windows 7 and Windows 8…Should work with Windows 10. Edit to your requirements. Paste this code into a new Windows Powershell ISE file, change the $orgName variable to your business name, and set the $logFile variable to a folder location and file location that you have access to. In this case you’ll need to create a folder called, “testlog” in C:\ .

Use at your own risk

function createCheckpoint
$logFile = 'C:\testlog\log.txt'
$provName = 'RapidEye Consulting'
$orgName = 'ACME Holdings Inc'
$date = Get-Date -format "yyyyMMdd"

# Message
$cpmsg = ("Creating restore point for " + $env:computername)
Write-Output ((Get-Date -Format "MM/dd/yyyy @ h:mm:sstt") + ' | ' + $cpmsg ) | Out-File $logFile -append -force

# check for checkpoint backup goodness and report back
if ((Checkpoint-Computer -Description ("$provName Backup Script for $orgName ($date)") -RestorePointType MODIFY_SETTINGS -ErrorAction SilentlyContinue) -ne $false)
$restoreMsg = "Restore point done."

} else
$restoreMsg = "Restore point could not be created for " + $env:computername


Write-Output ((Get-Date -Format "MM/dd/yyyy @ h:mm:sstt") + ' | ' + $restoreMsg ) | Out-File $logFile -append -force