23 lines
No EOL
688 B
PowerShell
23 lines
No EOL
688 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
|
|
RestorePointType = $restorePointType
|
|
Status = $status
|
|
Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
|
} | ConvertTo-Json |