From bc0222aa50b3eb42b306ed0944f3672d8553dd6e Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Wed, 17 Dec 2025 20:07:02 -0500 Subject: [PATCH] Update samy.ps1 --- samy.ps1 | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/samy.ps1 b/samy.ps1 index 8519abc..4a051d2 100644 --- a/samy.ps1 +++ b/samy.ps1 @@ -2693,9 +2693,17 @@ function Install-DattoRMM { $whHeaders.SAMYPW = $WebhookPassword } - $resp = Invoke-RestMethod -Uri $WebhookUrl ` - -Headers $whHeaders ` - -Method GET + $irmParams = @{ + Uri = $WebhookUrl + Method = 'Get' + ErrorAction = 'Stop' + ContentType = 'application/json' + } + + if ($whHeaders.Count -gt 0) { $irmParams.Headers = $whHeaders } + + $resp = Invoke-RestMethod @irmParams + $ApiUrl = $resp.ApiUrl $ApiKey = $resp.ApiKey @@ -2734,7 +2742,17 @@ function Install-DattoRMM { # 4) Fetch site list only if ($FetchSites) { try { - $sitesResp = Invoke-RestMethod -Uri "$ApiUrl/api/v2/account/sites" -Method Get -Headers $headers + $irmParams = @{ + Uri = "$ApiUrl/api/v2/account/sites" + Method = 'Get' + ErrorAction = 'Stop' + ContentType = 'application/json' + } + + if ($headers.Count -gt 0) { $irmParams.Headers = $headers } + + $sitesResp = Invoke-RestMethod @irmParams + $siteList = $sitesResp.sites | Sort-Object name | ForEach-Object { [PSCustomObject]@{ Name = $_.name; UID = $_.uid } }