# 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