Skip to main content

Microsoft Entra ID via Graph Explorer

Nothing to install. You run three queries in Graph Explorer in your browser, save each response as JSON, then run nc-export.py against the three files. If you would rather have the script call Graph for you, use the PowerShell path instead — both produce the same output file.

Read the privacy statement first if you have not already. This path performs zero network I/O in the script itself — every network call happens in your browser, against Graph Explorer, before the script ever runs.

Get the script​

Download nc-export.py and verify its checksum against the downloads page before you run it.

Run the queries and the script​

You need: Python 3.9 or newer (on Windows, where python3 is often the Microsoft Store stub, use py nc-export.py ... instead), and access to Graph Explorer signed in as an account that can read users, service principals and OAuth grants. Graph Explorer asks for the same three read-only scopes as the PowerShell path: User.Read.All, Application.Read.All, Directory.Read.All.

  1. Run three queries in Graph Explorer and save each response as JSON (Save response as JSON, or copy the body). Each is a Graph list document, {"value": [...]}, which is what the script expects.

    QuerySave as
    GET https://graph.microsoft.com/v1.0/usersusers.json
    GET https://graph.microsoft.com/v1.0/servicePrincipalsservicePrincipals.json
    GET https://graph.microsoft.com/v1.0/oauth2PermissionGrantsoauth2PermissionGrants.json

    If a response pages through @odata.nextLink, merge every page's value array into one {"value": [...]} file. The Graph Explorer guide has an example and the optional fourth query for app-role assignments.

  2. Run the script from the folder you downloaded it into. It reads only the files you name and makes no network calls.

    python3 nc-export.py entra \
    --users-json users.json \
    --service-principals-json servicePrincipals.json \
    --grants-json oauth2PermissionGrants.json \
    --out-dir ./out

The script performs no network I/O: it only reads the files you name on the command line and writes to --out-dir.

Paging and the optional fourth query​

Optionally, a fourth query adds app-role assignment grants (direct role-based app assignments, as distinct from OAuth consent grants) to the report — entirely optional and back-compatible; skip it and you simply get a report without that source:

QuerySave as
GET https://graph.microsoft.com/v1.0/servicePrincipals/{id}/appRoleAssignedTo (per service principal)appRoleAssignments.json

A large tenant may need to page through @odata.nextLink in Graph Explorer — save every page's value array into the same file (merged into one {"value": [...]} document) if so. Concretely, page one and page two each come back as their own {"value": [...]} document; you combine them into a single value array before saving:

// page 1
{"value": [{"id": "user-a"}, {"id": "user-b"}]}

// page 2
{"value": [{"id": "user-c"}]}

// users.json — merged
{"value": [{"id": "user-a"}, {"id": "user-b"}, {"id": "user-c"}]}

Add --app-role-assignments-json appRoleAssignments.json to the script command if you saved that fourth query.

What you'll see​

Skipped rows: 0
Nothing has been sent anywhere. Review discover-export.ndjson, then upload it in the Discover app.

Same closing message as the PowerShell path, byte-for-byte — both implementations are required to produce it identically.

If something goes wrong​

The script fails loudly rather than guessing. A few messages you might see, and what they mean:

  • '<path>' is not a Graph list response (missing a top-level "value" array) — the file you saved isn't a Graph list document. Re-save the response from Graph Explorer rather than a partial copy-paste.
  • invalid JSON in '<path>' — the file isn't valid JSON at all; re-export it.
  • warning: 0 grants were found in the source data -- this may indicate a permission or consent problem, not an empty tenant — printed to the terminal, not fatal. Check that the signed-in account actually has the three scopes above before assuming the tenant has none.

After it finishes​

  1. Open ./out/discover-export.ndjson and read it — see the export format page for the exact field-by-field shape.
  2. Leave ./out/mapping.csv and ./out/salt.txt on your machine. See the privacy statement for what they're for.
  3. In the setup wizard's Scan step, under Export file (discover-export.ndjson), click Choose file, select discover-export.ndjson, then click Upload.
Screenshot pending

The upload flow is live in Discover; a screenshot of this step is still being prepared and will be added here.

Next​