From 887762505465960a4cc530450f60615d97fb9c37 Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Sat, 20 Dec 2025 12:31:04 -0500 Subject: [PATCH] Update samy.ps1 --- samy.ps1 | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/samy.ps1 b/samy.ps1 index 2253318..a98b4af 100644 --- a/samy.ps1 +++ b/samy.ps1 @@ -2046,22 +2046,30 @@ function Install-DattoRMM { # 1) Optionally fetch credentials from webhook if ($UseWebhook) { - if (-not $WebhookPassword) { - Write-LogHybrid "Webhook password missing." Error DattoRMM -LogToEvent; return - } + + # Allow blank for IP allowlist scenario. Only treat true $null as missing. + if ($null -eq $WebhookPassword) { $WebhookPassword = '' } + Write-LogHybrid "Webhook password not provided (null). Treating as blank for allowlisted IP flow." Warning DattoRMM -LogToEvent + try { $resp = Invoke-RestMethod -Uri $WebhookUrl ` - -Headers @{ SAMYPW = $WebhookPassword } ` - -Method GET + -Headers @{ SAMYPW = [string]$WebhookPassword } ` + -Method GET ` + -ErrorAction Stop + $ApiUrl = $resp.ApiUrl $ApiKey = $resp.ApiKey $ApiSecretKey = $resp.ApiSecretKey + Write-LogHybrid "Webhook credentials fetched." Success DattoRMM -LogToEvent - } catch { - Write-LogHybrid "Failed to fetch webhook credentials: $($_.Exception.Message)" Error DattoRMM -LogToEvent; return + } + catch { + Write-LogHybrid "Failed to fetch webhook credentials: $($_.Exception.Message)" Error DattoRMM -LogToEvent + return } } + # 2) Validate API parameters if (-not $ApiUrl -or -not $ApiKey -or -not $ApiSecretKey) { Write-LogHybrid "Missing required API parameters." Error DattoRMM -LogToEvent; return