docs: document tenant comparison, bulk scope tags, full export, wrapper and lazy migration

README: intune wrapper, menu overview, batch/sorted export, tenant comparison
section, bulk scope tags, lazy group/filter creation. AGENTS.md: structure,
menu $menuDefs convention, folder picker, SettingOverrides, FullExportRoot.
This commit is contained in:
2026-11-24 13:12:55 +01:00
parent 57917e9183
commit cd0d516951
2 changed files with 48 additions and 5 deletions
+12 -3
View File
@@ -6,7 +6,7 @@
This repository is **macOS Intune Management** (also referred to as the IntuneManagement toolkit). It is a cross-platform, headless, PowerShell-first CLI for exporting, importing, migrating, and managing Microsoft Intune policies across tenants.
- **Current version:** `4.1.0` (see `VERSION`).
- **Current version:** `4.6.2` (see `VERSION`).
- **Primary workflow:** export policies from a source tenant as JSON, optionally capture assignments, then import them into a target tenant with app-only, browser, or device-code authentication.
- **Additional capabilities:** declarative baseline deployment from YAML, bulk assignment management, backup/restore of assignments, bulk device operations, policy rename, CSV/Markdown reporting from local backups, and a CIS M365 rapid baseline for tenant-level workloads.
- **Important historical note:** the old WPF UI surface has been removed. The repo is intentionally CLI-first and headless.
@@ -37,6 +37,7 @@ There is no compiled application, no `pyproject.toml`/`package.json`/`Cargo.toml
```text
.
├── Start-IntuneToolkit.ps1 # Unified terminal UI launcher (recommended entry point)
├── intune # Bash wrapper: launcher, or `intune <Script> [args]` without typing pwsh
├── Core.psm1 # Headless runtime helpers, settings, logging, module loader
├── Runtime/
│ ├── IntuneManagement.Runtime.psd1 # Module manifest
@@ -55,7 +56,8 @@ There is no compiled application, no `pyproject.toml`/`package.json`/`Cargo.toml
│ ├── Initialize-IntuneAuth.ps1 # One-time Entra app + secret setup
│ ├── Deploy-IntuneBaseline.ps1 # YAML-driven baseline deployer
│ ├── ConvertTo-IntuneBaseline.ps1 # Export folder → baseline skeleton
│ ├── *_Bulk*.ps1 # Assignments, rename, device operations
│ ├── *_Bulk*.ps1 # Assignments, rename, delete, scope tags, device operations
│ ├── Compare-Tenants.py # Offline comparison of two export folders (tenants A/B or drift)
│ ├── *.py # Reporting and PDF conversion utilities
│ └── Private/
│ └── Start-IntuneManagementTui.ps1
@@ -99,6 +101,8 @@ The toolkit stores persistent configuration in a platform-specific JSON settings
Per-tenant settings are stored under a key matching the tenant GUID. On macOS, the client secret is stored in the macOS Keychain (service `IntuneMgmt-<AppId>`, account `IntuneManagement`) instead of inside the JSON file. On non-macOS platforms the secret is written to the JSON file — treat that file as sensitive.
The launcher also stores `FullExportRoot` (last export root used by the full tenant export) in this file.
Operational logs are written to `IntuneManagement.log` in the same data folder by default.
## Authentication
@@ -123,7 +127,7 @@ The launcher caches tenant display names in `Settings.json` so the TUI can show
| Script | Purpose |
|---|---|
| `intune` | Bash wrapper (macOS/Linux): launcher by default, or `intune <Script> [args]` to run any `Scripts/*.ps1`/`*.py` without typing `pwsh`. Symlink onto PATH. |
| `Start-IntuneToolkit.ps1` | Unified reverse-numbered `fzf`/numbered menu; remembers tenants; launches all other tools. |
| `Start-IntuneToolkit.ps1` | `fzf`/numbered menu; remembers tenants; launches all other tools. Entries are a list in display order (`$menuDefs`); numbers are assigned automatically and each entry has a stable internal `Id` used for dispatch. Includes the full tenant export (dated folder + drift check) and tenant comparison. |
| `Scripts/Start-HeadlessIntune.ps1` | Single-action wrapper (`Export`, `Import`, `DeployCISBaseline`, `GenerateReports`) with optional interactive TUI. |
| `Scripts/Export-SettingsReport.py` | Generate a flat CSV of policy settings/values. Includes a `Platform` column and resolves Settings Catalog names from `configurationSettings.json` (auto-exported with Settings Catalog). |
| `Scripts/Compare-Tenants.py` | Offline comparison of two export folders (all categories incl. Autopilot, roles). Handles different name prefixes (`--strip-a/--strip-b`), fuzzy/content matching, optional `--include-assignments`. Writes Markdown + CSV. |
@@ -233,4 +237,9 @@ python3 -m py_compile Scripts/_ConvertFrom-CISPDF.py
- The project is deployed manually: clone the repository and run `pwsh ./Start-IntuneToolkit.ps1` or the relevant script.
- Version is tracked in the `VERSION` file and referenced by `README.md` and `CHANGELOG_macOS_IntuneToolkit.md`.
- There is no installer, no signed module package, and no automated release pipeline.
- Menu: add an entry to `$menuDefs` in `Start-IntuneToolkit.ps1` with a new unique `Id` and handle that `Id` in the dispatch `switch` or an `if($choiceNumber -eq <Id>)` block. Do not renumber ids.
- Folder prompts in the launcher/TUI use `Select-FolderPath` (`Scripts/Private/Select-FolderPath.ps1`, fzf browser with create-folder and a plain-prompt fallback).
- Run-level setting overrides: `$global:SettingOverrides` (hashtable, set by `Invoke-IntuneHeadlessBatch`, read first by `Get-SettingValue`, never persisted). Headless export sets `UseBatchAPI` (default on, `-NoBatchApi` to disable) and `SortJsonProperties`.
- Import migration is lazy: groups from the migration table (and exported assignment filters missing in the target) are created in `Update-JsonForEnvironment` only when an imported object references them.
- Verify batch vs non-batch export with `Compare-Tenants.py` on two exports of the same tenant (expect no differences).
- When adding a new workload or object type, register it in both `Extensions/EndpointManager.psm1` (as an `Add-ViewItem`) and `Headless/IntuneManagement.Headless.psm1` (in `Get-DefaultIntunePolicyObjectTypes`) if it should be available headlessly.
+36 -2
View File
@@ -2,7 +2,7 @@
Cross-platform, headless Intune policy export/import with PowerShell.
**Current version:** `4.4.1` — see [`CHANGELOG_macOS_IntuneToolkit.md`](CHANGELOG_macOS_IntuneToolkit.md) for recent changes.
**Current version:** `4.6.2` — see [`CHANGELOG_macOS_IntuneToolkit.md`](CHANGELOG_macOS_IntuneToolkit.md) for recent changes.
This repository is now CLI-first. The old WPF application surface has been removed from the repo. The supported workflow is:
@@ -24,6 +24,17 @@ If `fzf` is installed you get an interactive picker; otherwise you get a numbere
pwsh ./Start-IntuneToolkit.ps1 -TenantId "<tenant-id>"
```
On macOS/Linux the `intune` wrapper starts the same launcher without typing `pwsh`, and runs any script by name:
```bash
./intune # launcher
./intune Export-Policies -TenantId <id> -ExportPath ~/out # Scripts/Export-Policies.ps1
./intune Compare-Tenants --root-a A --root-b B # Scripts/Compare-Tenants.py
ln -s "$PWD/intune" ~/.local/bin/intune # optional: use it from anywhere
```
Launcher menu (numbers are assigned automatically in this order): export/import (including **Full tenant export** into a dated folder with an optional drift check against the previous export), bulk operations (assignments, rename, delete, **scope tags**, devices), baselines and compliance, reporting (reports, Entra role membership, **offline tenant comparison**) and tenant/auth administration. Folder prompts use an fzf folder browser with "create new folder".
## Entry points
* [Start-IntuneToolkit.ps1](/Users/avedelphina/Local/IntuneManagement/Start-IntuneToolkit.ps1) — unified launcher (recommended)
@@ -32,6 +43,8 @@ pwsh ./Start-IntuneToolkit.ps1 -TenantId "<tenant-id>"
* [Scripts/Import-Policies.ps1](/Users/avedelphina/Local/IntuneManagement/Scripts/Import-Policies.ps1)
* [Scripts/Initialize-IntuneAuth.ps1](/Users/avedelphina/Local/IntuneManagement/Scripts/Initialize-IntuneAuth.ps1) — one-time Entra app + secret + Keychain setup
* [Scripts/Export-SettingsReport.py](/Users/avedelphina/Local/IntuneManagement/Scripts/Export-SettingsReport.py) — generate a flat CSV of policy settings/values
* [Scripts/Compare-Tenants.py](Scripts/Compare-Tenants.py) — offline comparison of two export folders (see [Tenant comparison](#tenant-comparison))
* [Scripts/Bulk-ScopeTags.ps1](Scripts/Bulk-ScopeTags.ps1) — bulk add/replace/remove scope tags
* [Scripts/Export-EntraRoleMembership.ps1](/Users/avedelphina/Local/IntuneManagement/Scripts/Export-EntraRoleMembership.ps1) — export all active + PIM-eligible Entra directory role memberships (group assignments expanded) to CSV
* [Headless/IntuneManagement.Headless.psd1](/Users/avedelphina/Local/IntuneManagement/Headless/IntuneManagement.Headless.psd1)
@@ -55,6 +68,7 @@ The default headless policy scope is:
* `CompliancePolicies`
* `EndpointSecurity`
* `PolicySets`
* ... and about 40 more (scripts, Autopilot, enrollment, app protection, update policies including *Quality Updates (Profiles/Policies)*, role definitions, scope tags, filters, Conditional Access, ...). The full list is `Get-DefaultIntunePolicyObjectTypes` in [`Headless/IntuneManagement.Headless.psm1`](Headless/IntuneManagement.Headless.psm1).
You can override that list with `-ObjectTypes`.
@@ -77,6 +91,8 @@ pwsh ./Scripts/Export-Policies.ps1 `
-IncludeAssignments
```
Export uses the Graph batch API (20 objects per call) and writes JSON with sorted properties so repeated exports diff cleanly. Pass `-NoBatchApi` to fall back to one call per object. Role definitions are exported with their role assignments, including built-in roles; on import built-in roles are not created, their assignments are recreated only when assignments are imported.
## Export with browser auth
```powershell
@@ -145,6 +161,7 @@ pwsh ./Scripts/Start-HeadlessIntune.ps1 `
* **CIS M365 baseline** — [`Deploy-CISM365Baseline.ps1`](Scripts/Deploy-CISM365Baseline.ps1) applies the CIS Microsoft 365 v7 benchmark to a tenant. See [`Baselines/M365-CIS-Rapid/`](Baselines/M365-CIS-Rapid/) for a config-driven rapid baseline.
* **Bulk assignments** — [`Bulk-AssignmentManager.ps1`](Scripts/Bulk-AssignmentManager.ps1) adds or removes assignments for any policy type using the bulk `/assign` endpoint. [`Bulk-AppAssignment.ps1`](Scripts/Bulk-AppAssignment.ps1) does the same for applications.
* **Backup / restore assignments** — [`Backup-Restore-Assignments.ps1`](Scripts/Backup-Restore-Assignments.ps1) saves assignments to JSON and can restore them with cross-tenant group name resolution.
* **Bulk scope tags** — [`Bulk-ScopeTags.ps1`](Scripts/Bulk-ScopeTags.ps1) adds, replaces or removes scope tags across object types (optionally filtered by name) or cleans up tag ids that no longer exist. Shows the plan first, supports `-WhatIf`, `-Force` and non-interactive parameters (`-Action`, `-ScopeTags`, `-ObjectTypes`, `-NameFilter`).
* **Bulk rename** — [`Bulk-RenamePolicies.ps1`](Scripts/Bulk-RenamePolicies.ps1) performs search/replace or prefix mutations across policy names and descriptions.
* **Bulk delete** — [`Bulk-DeletePolicies.ps1`](Scripts/Bulk-DeletePolicies.ps1) deletes selected policies/apps by object type and name filter, requires typing `DELETE` to confirm, supports `-WhatIf`.
* **Device operations** — [`Bulk-DeviceOperations.ps1`](Scripts/Bulk-DeviceOperations.ps1) supports delete, retire, wipe, lock, and sync with `-WhatIf` safeguards.
@@ -153,10 +170,27 @@ pwsh ./Scripts/Start-HeadlessIntune.ps1 `
* **Baseline batch runner** — [`Invoke-BaselineBatch.ps1`](Scripts/Invoke-BaselineBatch.ps1) run multiple baseline manifests in one pass.
* **Conditional Access wizard** — [`Start-CAWizard.ps1`](Scripts/Start-CAWizard.ps1) / [`ca-wizard.py`](Scripts/ca-wizard.py) generate Conditional Access baseline skeletons.
## Tenant comparison
[`Compare-Tenants.py`](Scripts/Compare-Tenants.py) compares two export folders offline (no Graph calls): two tenants with different name prefixes and assignments, or two exports of one tenant to see drift.
```bash
./intune Compare-Tenants \
--root-a ~/Local/IntuneExports/SSD-261124 --label-a SSD --strip-a '^SSD\s*-\s*' \
--root-b ~/Local/IntuneExports/SSE-261124 --label-b SSE --strip-b '^SSE\s*-\s*' \
--output-dir ~/Local/IntuneExports/compare [--include-assignments]
```
* Works for every exported category (Settings Catalog, device configuration, compliance, Autopilot, ESP, roles, apps, ...). IDs, timestamps, scope tags, OData metadata and names are ignored; GUIDs are resolved to names through the exported groups and filters.
* Policies are matched by name after stripping the per-tenant prefix (`--strip-a/--strip-b`, regex), then by fuzzy name similarity (`--fuzzy-threshold`), then by near-identical content (`--content-threshold`). `--no-fuzzy` keeps exact matching only; every non-exact match is listed with its score.
* Output: `tenant-comparison.md` (summary per category, only-in-A/B, setting-level differences) and `tenant-comparison.csv`.
* Leave both prefixes blank to compare two exports of the same tenant. The **Full tenant export** menu entry offers this automatically after exporting.
## Notes
* Export writes a migration table used during cross-tenant import.
* Import can translate dependency IDs and recreate missing assignment groups.
* Import can translate dependency IDs. With *Import assignments*, Entra groups (and, with *Replace dependency ids*, assignment filters) are looked up or created in the target tenant only when an imported object references them. Synced source groups are created as cloud groups.
* Win32 app install/uninstall scripts are exported and recreated on import.
* This repo intentionally does not preserve the old Windows UI launch flow.
* Browser auth uses the system browser and a loopback redirect.
* If you omit `-AppId` with `-AuthMode Browser`, the CLI defaults to the Microsoft Graph PowerShell public client app id `14d82eec-204b-4c2f-b7e8-296a70dab67e`.