Added webhook
This commit is contained in:
parent
6c466f49f7
commit
286e684254
1 changed files with 29 additions and 1 deletions
28
cleanup.ps1
28
cleanup.ps1
|
|
@ -177,3 +177,31 @@ Write-Log "Windows update completed." -LEVEL "INFO"
|
||||||
Write-Log "Script completed at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" -Level "INFO"
|
Write-Log "Script completed at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" -Level "INFO"
|
||||||
Write-Log "Log file saved to: $LogFile" -Level "INFO"
|
Write-Log "Log file saved to: $LogFile" -Level "INFO"
|
||||||
"================================================================================" | Out-File -FilePath $LogFile -Append -Encoding UTF8
|
"================================================================================" | Out-File -FilePath $LogFile -Append -Encoding UTF8
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
# Send log to webhook
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
Write-Log "Sending log file to webhook..."
|
||||||
|
|
||||||
|
try {
|
||||||
|
# Read log file content
|
||||||
|
$LogContent = Get-Content -Path $LogFile -Raw -ErrorAction Stop
|
||||||
|
|
||||||
|
# Prepare webhook payload
|
||||||
|
$WebhookPayload = @{
|
||||||
|
"log_file" = $LogFile
|
||||||
|
"log_content" = $LogContent
|
||||||
|
"timestamp" = (Get-Date -Format "yyyy-MM-dd HH:mm:ss")
|
||||||
|
"status" = "completed"
|
||||||
|
} | ConvertTo-Json -Depth 3
|
||||||
|
|
||||||
|
# Send to webhook
|
||||||
|
$WebhookResponse = Invoke-WebRequest -Uri "https://n8n.questcomputers.be/webhook-test/99077b7d-140f-477e-9241-2b9581ddaf34" -Method POST -Body $WebhookPayload -ContentType "application/json" -ErrorAction Stop
|
||||||
|
|
||||||
|
Write-Log "Log file sent to webhook successfully. Status: $($WebhookResponse.StatusCode)" -Level "INFO"
|
||||||
|
} catch {
|
||||||
|
Write-Log "Failed to send log to webhook: $($_.Exception.Message)" -Level "ERROR"
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Log "Webhook notification completed." -Level "INFO"
|
||||||
|
"" | Out-File -FilePath $LogFile -Append -Encoding UTF8
|
||||||
Loading…
Add table
Add a link
Reference in a new issue