Our companion article covers the manual way to collect license-analysis data: eighteen-plus datasets, each exported one at a time through its own View/UI form, DMF export project, or Table Browser page. That takes about an hour and a half in a healthy environment, or a couple of hours with a table or two past a million rows, where you sort ascending, sort descending, and remove duplicates by hand to get past the platform's row-count ceiling on a single export.

For data in the F&O SQL database itself, there's a faster path: just-in-time access to a sandbox, then one script.

ℹ If you read one line

One JIT request and one unattended script run replace eighteen-plus manual exports, with about five minutes of hands-on time.

Step one: get just-in-time access to a Tier 2 sandbox

Just-in-time (JIT) database access is a Microsoft-native Lifecycle Services feature built for troubleshooting, ad hoc queries, and data problem-solving, which is what a license analysis is. It works only on a Tier 2+ sandbox, never production, so first confirm the client's sandbox was refreshed recently enough to reflect current security and license configuration.

On the environment's details page in LCS, select Maintain → Enable access, add the requesting machine's outbound IP address, and choose read or read-write access under Database Accounts. The grant expires after eight hours, or sooner if the database is refreshed or moved. LCS then shows the server and database names, and you connect as to any Azure SQL database. Full steps: Enable just-in-time database access on Microsoft Learn.

Confirm your IP before you assume the connection will work: run (Invoke-RestMethod -Uri "https://api.ipify.org?format=json").ip in PowerShell and compare it with LCS's firewall rule. A mismatch, common if you requested access on one network and run the script on another, gives no helpful error; the connection just quietly refuses.

Step two: run one script instead of roughly twenty exports

Our internal extraction script connects with the four values LCS hands you (SQL Server, Database Name, User name, Password) and pulls every SQL-reachable dataset in one run. It needs no install: just PowerShell 5.1, already on every Windows machine, and .NET's built-in System.Data.SqlClient. A hand-written CSV writer applies the RFC-4180 quoting the UI exports use, so a comma or line break in a Description field doesn't corrupt the file.

It lists all 33 datasets and runs everything or just the ones that changed:

PS C:\projects\license-data-extraction> .\extract-license-data.ps1
SQL Server: avantiico-jit-sbx-nam-d365opsprod-4b7e91fa2c3d.database.windows.net
Database Name: db_d365opsprod_democlient_ax_20260809_44219087_c812
User name: JIT-demo-h3n8q1
Password: [redacted, an 80+ character JIT-issued secret, valid for this session only]
(captured lengths -- server:58 db:47 user:15 password:88)

Available datasets:
   1. Active users                               -> active_users.csv
   2. Application users                          -> app_users.csv
   3. System security Role                       -> syssecurityrole.csv
   ...
  17. Invalid users                              -> invalid_users.csv
  18. Personalization: Relationships             -> personalization_relationships.csv
  19. Personalization: Views                     -> personalization_views.csv
  20. Personalization: Roles                     -> personalization_roles.csv
  21. Personalization: Summary                   -> personalization_summary.csv
  22. Audit prep: Table ID map                   -> audit_table_ids.csv
   ...
  31. Audit: Legacy DatabaseLog row counts by table -> audit_legacy_databaselog_counts.csv
  32. Audit: Custom-table stamp discovery (dynamic, custom tables only) -> audit_custom_table_*.csv (3 files)
  33. Audit: ALL tables system-wide stamp sweep (standard + custom, no gate) -> audit_all_table_*.csv (3 files)

Enter number(s) to run, comma-separated (e.g. 1,9,14), 'q' to quit without running anything, or press Enter for ALL:

Extracting Active users -> active_users.csv ...
  done: active_users.csv (140 rows)
Extracting Security analysis -> security_analysis.csv ...
  done: security_analysis.csv (511,204 rows)
Extracting License Role entitlement -> license_privilege.csv ...
  done: license_privilege.csv (1,502,880 rows)
...

Started:  2026-08-09 09:14:02
Finished: 2026-08-09 10:19:47  (elapsed: 01:05:45)

Datasets 1-31 (license through audit log) then run unattended for roughly ninety minutes, mostly on the two multi-million-row tables, Security analysis and License Role entitlement.

What's grown since the original 21

Bar chart: the script grew from 21 datasets (license, security, personalization) to 33 (adding audit-log evidence and dynamic table-wide sweeps).

The script started with 21 datasets (license, security, personalization) and now has 33. Ten audit-log datasets add schema discovery and who-changed-what-when pulls for the write-evidence half of the two-source disposition model. Two dynamic sweeps find audit-stamp-shaped tables live instead of using a fixed list: one covers custom tables only, the other all standard and custom tables with no exclusion filter. Both output a per-user aggregate (who touched a table, how many records), not a row-by-row log.

The sweeps are where "roughly ninety minutes" stops holding: the custom-tables sweep typically takes under a minute, but the system-wide sweep queries every table in the schema and can run considerably longer on a large tenant, so the script warns you first.

Not every engagement needs all 33. -Preset StructuralValidation runs exactly 11, the ones needed to validate a redesigned security config against a UAT/test environment with no usage evidence yet, and skips the dataset menu. See HOW_TO_RUN.md in the toolkit.
Bar chart comparing roughly two hours of active time for manual UI exports against roughly ninety minutes total for the script, of which only about five minutes is hands-on.
The script's run time is mostly unattended. The five minutes that actually needs a person is the JIT request.

The password prompt is deliberately unmasked: Read-Host -AsSecureString silently truncated pasted input to a single character on two terminal hosts. That's acceptable for a credential that dies in eight hours; just don't screenshot that line, and run cls afterward to clear scrollback.

It's this script, generalized from our own internal sandbox rather than any client's, plus three runbooks: running it, the engagement checklist (governance, JIT access, per-client schema validation), and installing bcp for one-off bulk exports the script doesn't need.

On first run, expect one Windows prompt: files downloaded from the internet, including out of a ZIP, are marked untrusted, and PowerShell blocks unsigned scripts from that zone by default. If it says the script "is not digitally signed. You cannot run this script on the current system," run Unblock-File .\extract-license-data.ps1 once, then run it normally. HOW_TO_RUN.md covers stricter execution policies.

What the script resolved that the original mapping left open

The dataset-to-table mapping used to live in a spreadsheet: dataset name, UI link, and a best guess at the F&O table. Three guesses carried a note along the lines of "I am not sure if it's the right table, check it." The script checked them against a live schema:

Two datasets stay outside the script, and it says so. Current license subscription lives in the Power Platform Admin Center, a separate Microsoft cloud service with no SQL path. Telemetry lives in Application Insights, reachable only through KQL. A full run names both at the end, so nothing comes up empty unexplained.

What this doesn't replace

StepManual (UI exports)JIT + script
Access setupStanding admin credentials~5 minutes, LCS request + IP check
Collection~18 separate exports, actively driven1 script run, unattended
Large-table handlingManual ascending/descending export + de-dupe past the row capHandled in one query per dataset
Total active time~1.5 to 2 hours~5 to 10 minutes
Total elapsed time~1.5 to 2 hours~80 to 95 minutes for datasets 1-31, mostly unattended; longer with the system-wide audit sweep (33) on a large tenant
✓ Bottom line

License subscription and telemetry aside, everything that used to mean eighteen manual exports is now one JIT request and one script run, plus twelve audit-log datasets a manual review never touched. Same data, same analysis, a fraction of the hands-on time. The manual walkthrough it replaces: what we collect and why.