From 4ddce9730fcc77a0a2ab000d6ebd07e189cb63f1 Mon Sep 17 00:00:00 2001 From: Damian West Date: Mon, 12 May 2025 15:58:17 +1000 Subject: [PATCH] Update Invoke-CWMWebRequest.ps1 to include -AllowInsecureRedirect Adds -AllowInsecureRedirect to the Invoke-WebRequest to allow proper communication with the ConnectWise servers. I have not investigated this properly for security issues, however nothing seems to have changed on CW end but since the implementation of this in PowerShell it will no longer return ID's on New-CWM* commands, this will fix. Fixes Issue #70 --- .../Private/Invoke/Invoke-CWMWebRequest.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ConnectWiseManageAPI/Private/Invoke/Invoke-CWMWebRequest.ps1 b/ConnectWiseManageAPI/Private/Invoke/Invoke-CWMWebRequest.ps1 index f7c1e77..59f2c1d 100644 --- a/ConnectWiseManageAPI/Private/Invoke/Invoke-CWMWebRequest.ps1 +++ b/ConnectWiseManageAPI/Private/Invoke/Invoke-CWMWebRequest.ps1 @@ -42,7 +42,7 @@ $prevProgressPreference = $global:ProgressPreference $global:ProgressPreference = 'SilentlyContinue' - $Result = Invoke-WebRequest @Arguments -UseBasicParsing + $Result = Invoke-WebRequest @Arguments -UseBasicParsing -AllowInsecureRedirect $global:ProgressPreference = $prevProgressPreference } @@ -122,7 +122,7 @@ Write-Warning "Issue with request, status: $($Result.StatusCode) $($Result.StatusDescription)" Write-Warning "$($Retry)/$($MaxRetry) retries, waiting $($Wait)ms." Start-Sleep -Milliseconds $Wait - $Result = Invoke-WebRequest @Arguments -UseBasicParsing + $Result = Invoke-WebRequest @Arguments -UseBasicParsing -AllowInsecureRedirect } if ($Retry -ge $MaxRetry) { return Write-Error "Max retries hit. Status: $($Result.StatusCode) $($Result.StatusDescription)" @@ -134,4 +134,4 @@ } $Result -} \ No newline at end of file +}