Scripts

SCRIPT / MICROSOFT 365

Microsoft 365 Tenant Information Script

A read-only sample script pattern for collecting a small, reviewable tenant snapshot.

What it collects

The example keeps its scope intentionally narrow: an organization name, verified domains, and a timestamp. A useful inventory script should be explicit about what it reads and what it writes.

Script

[CmdletBinding()]
param(
  [string]$OutputPath = "./tenant-snapshot.json"
)
 
$snapshot = [ordered]@{
  CollectedAt = (Get-Date).ToUniversalTime().ToString("o")
  Purpose     = "Static North fictional demo"
  Organization = "Replace with approved read-only lookup"
  Domains      = @("example.invalid")
}
 
$snapshot |
  ConvertTo-Json -Depth 4 |
  Set-Content -Path $OutputPath -Encoding utf8
 
Write-Verbose "Wrote sample snapshot to $OutputPath"

Design notes

The parameter has a harmless local default, structured data is built before serialization, and the output identifies itself as a demo. In a real script, connection setup and Graph permissions should be separate, documented concerns.

Example invocation

pwsh ./Get-TenantSnapshot.ps1 -Verbose

Expected output shape

{
  "CollectedAt": "2026-08-18T17:42:00.0000000Z",
  "Purpose": "Static North fictional demo",
  "Organization": "Replace with approved read-only lookup",
  "Domains": ["example.invalid"]
}

Operational notes

Do not commit real tenant exports if they contain internal identifiers. Decide retention and access rules before expanding the inventory.