Quick start¶
Prerequisites¶
- PowerShell 5.1+ or PowerShell 7+. The scripts declare
#Requires -Version 5.1, so they run on stock Windows PowerShell 5.1 as well as PowerShell 7 (macOS, Windows, Linux). On 5.1, CSV output is UTF-8 with a BOM (PowerShell 7 omits it) - Excel, Power BI, andImport-Csvall read either form. ExchangeOnlineManagementmodule (providesConnect-IPPSSessionandExport-ContentExplorerData). Use v3 or later - on Windows PowerShell 5.1 the connection probe prefersGet-ConnectionInformation, which v3+ supplies (it falls back toGet-Labelon older modules):Pester5+ - only needed if you want to run the offline unit tests:- Microsoft 365 account with the
Content Explorer List Viewerrole group assigned in Microsoft Purview. Without this,Export-ContentExplorerDatareturns "access denied" for every call.
Install¶
Clone the repository - the scripts run in place:
git clone https://github.com/LukeEvansTech/purview-content-explorer-export.git
cd purview-content-explorer-export
The scripts are already executable in the repository. If chmod got stripped:
Verify Pester tests still pass:
Run¶
# 1. Connect interactively (one-time per shell session, ~1h token life).
Connect-IPPSSession
# 2. Dry-run to see which SITs would be swept — no item exports yet.
./Invoke-CESweep.ps1 -DryRun
# 3. Sweep. Default is all SensitiveInformationTypes across all four workloads.
./Invoke-CESweep.ps1
Output lands in ./output/:
items_<TagType>_<safe-name>.csv- one per(TagType, TagName)that had at least one hititems_all.csv- concatenation of all per-tag files, schemas unioned (load this into Excel / Power BI)sweep.log- append-only timestamped status log
Curate your include list
Sweeping all 300+ tenant SITs typically takes many hours and most of them won't be relevant to your DLP policies. Maintain a CSV of the ~50 names you actually care about and pass it via -NamesFile. See Common scenarios for examples.
Verify it worked¶
After the sweep finishes, you should see a summary like:
The roll-up CSV is the file you'll work with:
Open it in Excel / Power BI and pivot by TagName × Workload to see where each SIT is finding hits.