From 8f414878a742596f3c4298ed5846aed57b590532 Mon Sep 17 00:00:00 2001 From: "Jason Thompson (ID CXP)" Date: Fri, 24 Mar 2023 13:16:31 -0400 Subject: [PATCH] fix email lookup when # symbol is present --- src/internal/Confirm-ModuleAuthentication.ps1 | 12 ++++++------ src/internal/Get-MsGraphResults.ps1 | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/internal/Confirm-ModuleAuthentication.ps1 b/src/internal/Confirm-ModuleAuthentication.ps1 index 66733d9..f8761be 100644 --- a/src/internal/Confirm-ModuleAuthentication.ps1 +++ b/src/internal/Confirm-ModuleAuthentication.ps1 @@ -25,6 +25,12 @@ function Confirm-ModuleAuthentication { [string[]] $MsGraphScopes = $script:MsGraphScopes ) + ## Throw error if no client application exists + if (!$script:ConnectState.ClientApplication) { + $Exception = New-Object System.Security.Authentication.AuthenticationException -ArgumentList ('You must call the Connect-AADAssessment cmdlet before calling any other cmdlets.') + Write-Error -Exception $Exception -Category ([System.Management.Automation.ErrorCategory]::AuthenticationError) -CategoryActivity $MyInvocation.MyCommand -ErrorId 'ConnectAADAssessmentRequired' -ErrorAction Stop + } + ## Override scopes on microsoft tenant only if ($ClientApplication.AppConfig.TenantId -in ('72f988bf-86f1-41af-91ab-2d7cd011db47', 'microsoft.onmicrosoft.com', 'microsoft.com') -and $ClientApplication.ClientId -in ('1b730954-1685-4b74-9bfd-dac224a7b894', '1950a258-227b-4e31-a9cf-717495945fc2', '65df9042-2439-4b70-94ac-6cc892f61d85')) { $MsGraphScopes = '.default' } @@ -37,12 +43,6 @@ function Confirm-ModuleAuthentication { if (!$MsGraphScopes.Contains('openid')) { $MsGraphScopes += 'openid' } - ## Throw error if no client application exists - if (!$script:ConnectState.ClientApplication) { - $Exception = New-Object System.Security.Authentication.AuthenticationException -ArgumentList ('You must call the Connect-AADAssessment cmdlet before calling any other cmdlets.') - Write-Error -Exception $Exception -Category ([System.Management.Automation.ErrorCategory]::AuthenticationError) -CategoryActivity $MyInvocation.MyCommand -ErrorId 'ConnectAADAssessmentRequired' -ErrorAction Stop - } - ## Initialize #if (!$User) { $User = Get-MsalAccount $script:ConnectState.ClientApplication | Select-Object -First 1 -ExpandProperty Username } if ($script:AppInsightsRuntimeState.OperationStack.Count -gt 0) { diff --git a/src/internal/Get-MsGraphResults.ps1 b/src/internal/Get-MsGraphResults.ps1 index d5fab59..a94537a 100644 --- a/src/internal/Get-MsGraphResults.ps1 +++ b/src/internal/Get-MsGraphResults.ps1 @@ -545,7 +545,7 @@ function Get-MsGraphResults { if ($id) { ## If the URI contains '{0}', then replace it with Unique Id. if ($uriQueryEndpoint.Uri.AbsoluteUri.Contains('%7B0%7D')) { - $uriQueryEndpointUniqueId = New-Object System.UriBuilder -ArgumentList ([System.Net.WebUtility]::UrlDecode($uriQueryEndpoint.Uri.AbsoluteUri) -f $id) + $uriQueryEndpointUniqueId = New-Object System.UriBuilder -ArgumentList ([System.Net.WebUtility]::UrlDecode($uriQueryEndpoint.Uri.AbsoluteUri) -f [System.Net.WebUtility]::UrlEncode($id)) } else { $uriQueryEndpointUniqueId = New-Object System.UriBuilder -ArgumentList $uriQueryEndpoint.Uri