microsoft / EntraExporter

PowerShell module to export a local copy of an Entra (Azure AD) tenant configuration.
https://aka.ms/EntraExporter
MIT License
568 stars 89 forks source link

USGov Support #53

Closed tbisque closed 1 year ago

tbisque commented 1 year ago

Overview

Export-Entra does not seem to support USGov endpoints, or other national cloud endpoints.

Connect-EntraExporter Approach

The Connect-EntraExporter -Environment USGov is successful, however when running the Export-Entra with the -Debug parameter, it appears the graph.microsoft.com endpoint is being used.

Connect-MgGraph Approach

I also tested with connecting to graph directly (with -Environment USGov there as well), but Export-Entra has the same result. It still attempts to use the .com endpoint.

Suggestion

With the new (Get-MgContext).Environment, this may be easier to handle this than it was in the past.

SamErde commented 1 year ago

Nice PR! I hadn't gotten around to re-testing with Merill's latest release yet. Connect-EntraExporter seemed to cover most exporter functions previously, but it definitely helps to specify the .US endpoint (or others) directly.

One thing I wonder about: would it make sense to grab the GraphBaseUri once (maybe during the initial connection) with -GraphBaseUri "$((Get-MgEnvironment -Name (Get-MgContext).Environment).GraphEndpoint)"? A global variable for the rest of the script to use might simplify code management and make it a tiny bit faster. Thoughts?

tbisque commented 1 year ago

Good thinking @SamErde. I like that approach better than mine. I can get that added.

merill commented 1 year ago

Thanks @tbisque for the PR and @SamErde for the suggestion to optimise. I've tweaked the code with the suggestion from @SamErde

The latest module is being deployed to the gallery and should work well with the gov clouds.