Powershell - Managing System Restore Points in Windows

To support me, you can subscribe to the channel, share and like the videos, disable your ad blocker or make a donation. Thank you!

Hello,

This article describes how to manage system restore points in Windows using Powershell.

Restore points allow you to return to a previous state of your Windows without affecting your documents.

They can be accessed directly from Windows and also from the Windows Recovery Environment.

Some actions are not available from Powershell commands but from the native vssadmin command.
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/vssadmin-resize-shadowstorage

# Enable System Restore
Enable-ComputerRestore -Drive c:
# Define the maximum amount of disk space used by restore points (as a percentage of the volume size)
vssadmin resize shadowstorage /for=C: /on=C: /maxsize=5%
# Define the maximum amount of disk space used by restore points
vssadmin resize shadowstorage /for=C: /on=C: /maxsize=10GB
# Store restore points from volume C: on volume D: with no disk space limit
vssadmin resize shadowstorage /For=C: /On=D: /MaxSize=UNBOUNDED
# Display the space used by restore points
vssadmin list shadowstorage
# Disable system restore
Disable-ComputerRestore -Drive C:
# Create a restore point
Checkpoint-Computer -Description 'Before the tragedy'
# Create a restore point by specifying the type (default APPLICATION_INSTALL)
Checkpoint-Computer -Description 'Before the tragedy' -RestorePointType MODIFY_SETTINGS
# Available values: APPLICATION_INSTALL, APPLICATION_UNINSTALL, DEVICE_DRIVER_INSTALL, MODIFY_SETTINGS and CANCELLED_OPERATION
# Display restore points
Get-ComputerRestorePoint
# Restore a restore point, the ID to use is the SequenceNumber
Restore-Computer -RestorePoint 2
# Restore the last (most recent) restore point
Restore-Computer -RestorePoint (Get-ComputerRestorePoint)[-1].sequencenumber
#Display the status of the last restore operation
Get-ComputerRestorePoint -LastStatus
# Delete all restore points
vssadmin delete shadows /all
# Delete the oldest restore point
vssadmin Delete Shadows /For=C: /Oldest
# Delete a specific restore point
vssadmin list shadows /for=c:
# Retrieve the restore point id in the form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX}
vssadmin delete shadows /Shadow={XXXXXXXX-XXXX-XXXX-XXXXXXXXXXXX}
# By default, the system is limited to creating 1 restore point per day
# Deactivate the restore point limitation
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore' -Name SystemRestorePointCreationFrequency -Type DWORD -Value 0

Related links