scripts/create_restorepoint.ps1
2026-02-20 16:15:48 +01:00

20 lines
No EOL
637 B
PowerShell

# Check if a Name variable was passed from the calling script
# If not, generate a default name (e.g., for manual use or other scripts)
if (-not $Name) {
$Name = "RestorePoint-$(Get-Date -Format 'yyyy-MM-dd-HHmmss')"
}
try {
# Create the restore point using the $Name variable
Checkpoint-Computer -Description $Name -RestorePointType "Application" -ErrorAction Stop
$status = "Success"
} catch {
$status = "Failed: $($_.Exception.Message)"
}
# Return the result as JSON (the main script expects JSON)
@{
Name = $Name
Status = $status
Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
} | ConvertTo-Json