From 2c9b470f8055fbeb6147c8b0783f2f34240fa7a4 Mon Sep 17 00:00:00 2001 From: John Duprey Date: Fri, 2 Aug 2024 13:15:22 -0400 Subject: [PATCH] Clean up duplicate webhook entries --- .../Webhooks/Push-Schedulerwebhookcreation.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Webhooks/Push-Schedulerwebhookcreation.ps1 b/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Webhooks/Push-Schedulerwebhookcreation.ps1 index e893aac710ba..bba8630e91c5 100644 --- a/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Webhooks/Push-Schedulerwebhookcreation.ps1 +++ b/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Webhooks/Push-Schedulerwebhookcreation.ps1 @@ -22,6 +22,13 @@ function Push-Schedulerwebhookcreation { if ($Row.tenantid -ne 'AllTenants') { Remove-AzDataTableEntity @Table -Entity $Row } + if (($Webhook | Measure-Object).Count -gt 1) { + $Webhook = $Webhook | Select-Object -First 1 + $WebhooksToRemove = $ExistingWebhooks | Where-Object { $_.RowKey -ne $Webhook.RowKey } + foreach ($RemoveWebhook in $WebhooksToRemove) { + Remove-AzDataTableEntity @WebhookTable -Entity $RemoveWebhook + } + } } else { Write-Information "No existing webhook for $Tenant - $($Row.webhookType) - Time to create." try {