This commit is contained in:
Joeri 2026-02-20 16:29:42 +01:00
parent 524df826be
commit 2ab6f7bfe7

View file

@ -1,20 +1,23 @@
# Check if a Name variable was passed from the calling script # 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) { if (-not $Name) {
$Name = "RestorePoint-$(Get-Date -Format 'yyyy-MM-dd-HHmmss')" $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 { try {
# Create the restore point using the $Name variable Checkpoint-Computer -Description $Name -RestorePointType $restorePointType -ErrorAction Stop
Checkpoint-Computer -Description $Name -RestorePointType "Application" -ErrorAction Stop
$status = "Success" $status = "Success"
} catch { } catch {
$status = "Failed: $($_.Exception.Message)" $status = "Failed: $($_.Exception.Message)"
} }
# Return the result as JSON (the main script expects JSON) # Return the result as JSON
@{ @{
Name = $Name Name = $Name
RestorePointType = $restorePointType
Status = $status Status = $status
Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
} | ConvertTo-Json } | ConvertTo-Json