Updated
This commit is contained in:
parent
524df826be
commit
2ab6f7bfe7
1 changed files with 7 additions and 4 deletions
|
|
@ -1,20 +1,23 @@
|
|||
# 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')"
|
||||
}
|
||||
|
||||
# Define the RestorePointType
|
||||
# Use APPLICATION_INSTALL for cleanup tasks (treats it like an "install" that can be rolled back)
|
||||
$restorePointType = "MODIFY_SETTINGS"
|
||||
|
||||
try {
|
||||
# Create the restore point using the $Name variable
|
||||
Checkpoint-Computer -Description $Name -RestorePointType "Application" -ErrorAction Stop
|
||||
Checkpoint-Computer -Description $Name -RestorePointType $restorePointType -ErrorAction Stop
|
||||
$status = "Success"
|
||||
} catch {
|
||||
$status = "Failed: $($_.Exception.Message)"
|
||||
}
|
||||
|
||||
# Return the result as JSON (the main script expects JSON)
|
||||
# Return the result as JSON
|
||||
@{
|
||||
Name = $Name
|
||||
RestorePointType = $restorePointType
|
||||
Status = $status
|
||||
Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
||||
} | ConvertTo-Json
|
||||
Loading…
Add table
Add a link
Reference in a new issue