From 286e68425472acb8601a417a63c33644e6105ded Mon Sep 17 00:00:00 2001 From: Joeri Date: Sat, 7 Feb 2026 10:33:26 +0100 Subject: [PATCH] Added webhook --- cleanup.ps1 | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/cleanup.ps1 b/cleanup.ps1 index 189a2cc..8f8695d 100644 --- a/cleanup.ps1 +++ b/cleanup.ps1 @@ -176,4 +176,32 @@ 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 "Log file saved to: $LogFile" -Level "INFO" -"================================================================================" | Out-File -FilePath $LogFile -Append -Encoding UTF8 \ No newline at end of file +"================================================================================" | 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 \ No newline at end of file