scripts/create_restorepoint.ps1
2026-02-20 16:30:49 +01:00

22 lines
No EOL
647 B
PowerShell

# Check if a Name variable was passed from the calling script
if (-not $Name) {
$Name = "RestorePoint-$(Get-Date -Format 'yyyy-MM-dd-HHmmss')"
}
# Define the RestorePointType
# Use APPLICATION_INSTALL for cleanup tasks (treats it like an "install" that can be rolled back)
$restorePointType = "MODIFY_SETTINGS"
try {
Checkpoint-Computer -Description $Name -RestorePointType $restorePointType -ErrorAction Stop
$status = "Success"
} catch {
$status = "Failed: $($_.Exception.Message)"
}
# Return the result as JSON
@{
Name = $Name
Status = $status
Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
} | ConvertTo-Json