System Restore Point - Auto Purge after x thresholds
Overview
This PowerShell script automates the creation of a system restore point by first enabling System Restore on all valid internal NTFS drives and ensuring the required services are running. It then creates a restore point labeled Automated Restore Point.
The script intelligently filters out invalid or external drives and optionally performs cleanup of older shadow copies based on a configurable threshold, helping to manage disk space efficiently.
It supports environment-based input for drive letters and threshold values, making it highly adaptable for deployment via RMM platforms. This solution is ideal for pre-update safety, rollback readiness, and compliance-driven environments.
Implementation
- 
Import the componentSystem Restore Point - Auto Purge after x thresholds
- 
After downloading the attached file > Click on the Importbutton > Select the component to add to the Datto RMM interface. 
Sample Run
To execute the component over a specific machine, follow these steps:
- 
Select the machine you want to run the componenton from the Datto RMM.
- 
Click on the Quick Jobbutton.

- Select the respective componentfrom the list of availablecomponents.

- After selecting the componenet, you will see 3 variables :DriveLetters,Threshold, andForcecheckbox.

DriveLetters
- This variable is used to specify the drive letters that you want to enable system restore point upon. You can enter multiple drive letters separated by a comma.
- For example, C,D,E.
- If you do not provide any specific driver letter, the componentby default will create a restore over theSystem Drive.

Threshold
- Limits how many restore points are kept. Older ones are deleted if the limit is exceeded.
- For example, 2asThresholdwill create a new restore point and will only keep 2 latest restore points. Rest all will get deleted.

Force
- This is a checkbox that you can use to force the creation of a restore point.
- This can be helpful when you do not want to delete any older restore point then.
- By enabling Forceoption, thecomponentwill create a new restore point without purging any older ones.

Datto Variables
| Variable Name | Type | Default | Description | 
|---|---|---|---|
| DriveLetters | String | if no letter given, restore point will create on System Drive | Comma-separated drive letters to enable System Restore on (e.g., C, D, E). Leave blank for system drive only. | 
| Threshold | String | set a value | Limits how many restore points are kept. Older ones are deleted if the limit is exceeded | 
| Force | Boolean | False | Use Trueto bypass threshold if it's not set. Allows restore point creation without cleanup. | 
Output
- stdOut
- stdError