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 } }