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
|
# 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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue