From cdea456885fa58564afd81ea2e4bf563579ab35b Mon Sep 17 00:00:00 2001 From: Jiri Formacek Date: Sun, 4 Feb 2024 11:25:48 +0100 Subject: [PATCH] fix: PS Desktop without IE --- Module/ExoHelper/ExoHelper.psd1 | 2 +- Module/ExoHelper/ExoHelper.psm1 | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Module/ExoHelper/ExoHelper.psd1 b/Module/ExoHelper/ExoHelper.psd1 index 46faf83..fb9f712 100644 --- a/Module/ExoHelper/ExoHelper.psd1 +++ b/Module/ExoHelper/ExoHelper.psd1 @@ -12,7 +12,7 @@ RootModule = 'ExoHelper.psm1' # Version number of this module. -ModuleVersion = '1.0.4' +ModuleVersion = '1.0.5' # Supported PSEditions CompatiblePSEditions = @('Desktop', 'Core') diff --git a/Module/ExoHelper/ExoHelper.psm1 b/Module/ExoHelper/ExoHelper.psm1 index 2109e37..d8de79d 100644 --- a/Module/ExoHelper/ExoHelper.psm1 +++ b/Module/ExoHelper/ExoHelper.psm1 @@ -197,8 +197,25 @@ This command retrieves mailbox of user JohnDoe and returns just netId property #provide up to date token for each request of commands returning paged results that may take long to complete $headers['Authorization'] = (Get-ExoToken).CreateAuthorizationHeader() Write-Verbose "RequestId: $($headers['client-request-id'])`tUri: $pageUri" - - $response = Invoke-WebRequest -Uri $pageUri -Method Post -Body ($body | ConvertTo-Json -Depth 9) -Headers $headers -ContentType 'application/json' -ErrorAction Stop -Verbose:$false + $splat = @{ + Uri = $pageUri + Method = 'Post' + Body = ($body | ConvertTo-Json -Depth 9) + Headers = $headers + ContentType = 'application/json' + ErrorAction = 'Stop' + Verbose = $false + } + #add edition-specific parameters + if($PSEdition -eq 'Desktop') + { + $splat['UseBasicParsing'] = $true + } + else + { + $splat['ProgressAction'] = 'SilentlyContinue' + } + $response = Invoke-WebRequest @splat #we may process the headers in the future to see rate limit remaining, etc. $responseHeaders = $response.Headers