Fixes #2950
The fix provided here only works once when an absolute uri is passed to Invoke-MgGraphRequest cmdlet after connecting to a national cloud environment. Subsequent requests after the first successful one fails.
Changes proposed in this pull request
Added Microsoft graph context check in Find-MgGraphPermission in order to get the correct environment and extract the correct graph endpoint instead of using the default graph one (https://graph.microsoft.com) assigned to global environment.
Reset GraphSession environment back to its original state defined by the user.
Test scenarios.
Check that Find-MgGraphPermission does not default the session to the global graph endpoint after connecting to a national cloud environment.
Subsequent calls to graph endpoints do not fail after connecting to a national cloud environment.
Fixes #2950 The fix provided here only works once when an absolute uri is passed to
Invoke-MgGraphRequest
cmdlet after connecting to a national cloud environment. Subsequent requests after the first successful one fails.Changes proposed in this pull request
Find-MgGraphPermission
in order to get the correct environment and extract the correct graph endpoint instead of using the default graph one (https://graph.microsoft.com) assigned to global environment.Test scenarios.
Find-MgGraphPermission
does not default the session to the global graph endpoint after connecting to a national cloud environment.NB: See attached image below for the above tests