20 lines
No EOL
637 B
PowerShell
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 |