-
This commit is contained in:
parent
f469f3a444
commit
ef0c35fcef
2 changed files with 28 additions and 7 deletions
|
|
@ -78,7 +78,7 @@ if ($result -eq [System.Windows.Forms.DialogResult]::OK) {
|
||||||
|
|
||||||
# Send webhook
|
# Send webhook
|
||||||
try {
|
try {
|
||||||
$CreateRestorePoint = irm $ScriptCreateRestorePoint | iex -ArgumentList $ticket, $ScriptStartTime, $ScriptResult
|
$CreateRestorePoint = irm $ScriptCreateRestorePoint | iex
|
||||||
$GetComputerInfo = irm $ScriptGetComputerInfo | iex
|
$GetComputerInfo = irm $ScriptGetComputerInfo | iex
|
||||||
$GetInstalledAV = irm $ScriptGetInstalledAV | iex
|
$GetInstalledAV = irm $ScriptGetInstalledAV | iex
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,43 @@
|
||||||
|
# ==========================================
|
||||||
|
# 1. Setup Variables (Fix for missing vars)
|
||||||
|
# ==========================================
|
||||||
|
$TicketNumber = "INC-12345" # Your Ticket Number
|
||||||
|
$ScriptStartTime = Get-Date # Current DateTime object
|
||||||
|
$LogFile = "C:\Logs\QuestCleanup.log" # Path to your log file
|
||||||
|
$ScriptResult = @{} # Initialize the result hashtable
|
||||||
|
|
||||||
|
# (Optional) Define Write-Log if it is not available in your environment
|
||||||
|
function global:Write-Log {
|
||||||
param(
|
param(
|
||||||
[string]$TicketNumber,
|
[string]$Message,
|
||||||
[datetime]$ScriptStartTime,
|
[string]$Level = "INFO"
|
||||||
[object]$ScriptResult
|
|
||||||
)
|
)
|
||||||
|
"$Level - $Message"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ==========================================
|
||||||
|
# 2. Main Script Logic
|
||||||
|
# ==========================================
|
||||||
|
|
||||||
$RestorePointName = "QUEST-CLEANUP-$($TicketNumber -replace '[^A-Za-z0-9]', '')-$($ScriptStartTime.ToString('yyyy-MM-dd'))"
|
$RestorePointName = "QUEST-CLEANUP-$($TicketNumber -replace '[^A-Za-z0-9]', '')-$($ScriptStartTime.ToString('yyyy-MM-dd'))"
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Write-Log "Creating initial restore point: $RestorePointName"
|
Write-Log "Creating initial restore point: $RestorePointName"
|
||||||
|
|
||||||
|
# Requires Admin Rights and System Restore enabled
|
||||||
Checkpoint-Computer -Description $RestorePointName -ErrorAction Stop
|
Checkpoint-Computer -Description $RestorePointName -ErrorAction Stop
|
||||||
|
|
||||||
$ScriptResult.restore_point_initial.created = $true
|
$ScriptResult.restore_point_initial.created = $true
|
||||||
$ScriptResult.restore_point_initial.name = $RestorePointName
|
$ScriptResult.restore_point_initial.name = $RestorePointName
|
||||||
Write-Log "Initial restore point created successfully."
|
Write-Log "Initial restore point created successfully."
|
||||||
} catch {
|
}
|
||||||
|
catch {
|
||||||
$ErrorMsg = "Failed to create initial restore point: $($_.Exception.Message)"
|
$ErrorMsg = "Failed to create initial restore point: $($_.Exception.Message)"
|
||||||
$ScriptResult.restore_point_initial.error = $ErrorMsg
|
$ScriptResult.restore_point_initial.error = $ErrorMsg
|
||||||
Write-Log $ErrorMsg -Level "ERROR"
|
Write-Log $ErrorMsg -Level "ERROR"
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Log "Initial restore point section completed."
|
Write-Log "Initial restore point section completed."
|
||||||
|
|
||||||
|
# Appends a blank line to the log file
|
||||||
"" | Out-File -FilePath $LogFile -Append -Encoding UTF8
|
"" | Out-File -FilePath $LogFile -Append -Encoding UTF8
|
||||||
Loading…
Add table
Add a link
Reference in a new issue