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Mm`QoF|~vYvj&5iMa9FnYPI
zz))K@l~javj7upcP%*#Y%9k{Oz5`D_bHBlIc5j>(F|vN0lB8=o^{{Gy@&r|l`KaaS
zyC_YOHY}k%5dz7y84G!{4OR}r`Nbn~hVX0-u00p5m}sxw_7#y=O(Zky_h+djipQ*a
zoHp8lsJdZqnf$tiXM_p*-8WRnKSJcsd1+U)50+for8DaeuWZ^9^{AEgFEKYD5DLKm
z>@NOW3;vh!e|wGp8UIhq=f8t1{(6@Gdjse{G5%>Z`!|LM*#EFw|BDdkpJD&(^8Y(*fb@Up`TrB*pDn|GL$p!;8{+>o5dRteM04
f;VN|hA2q(bH0a;;{+I6@0s!al*VE?t*X(}*tEdTr
literal 0
HcmV?d00001
diff --git a/scripts/package-triage-toolkit.ps1 b/scripts/package-triage-toolkit.ps1
new file mode 100644
index 0000000..717b659
--- /dev/null
+++ b/scripts/package-triage-toolkit.ps1
@@ -0,0 +1,49 @@
+#requires -Version 7.5
+[CmdletBinding()]
+param([switch]$Check)
+$ErrorActionPreference = 'Stop'
+$repo = Split-Path $PSScriptRoot -Parent
+$source = Join-Path $repo 'tools/microsoft-365-incident-triage-toolkit'
+$destination = Join-Path $repo 'assets/downloads/microsoft-365-incident-triage-toolkit.zip'
+$files = @('Export-M365IncidentTriage.ps1', 'M365IncidentTriage.psm1', 'README.md',
+ 'demo-snapshot.json', 'escalation-template.md', 'samples/evidence.json',
+ 'samples/report.md', 'tests/Test-M365IncidentTriage.ps1') | Sort-Object
+$sample = Get-Content -LiteralPath (Join-Path $source 'samples/evidence.json') -Raw | ConvertFrom-Json -AsHashtable -DateKind String
+if ($sample.Mode -ne 'Demo' -or $sample.TenantId -ne 'SYNTHETIC — no tenant') {
+ throw 'Only the synthetic demo sample may be packaged.'
+}
+Add-Type -AssemblyName System.IO.Compression
+if ($Check) {
+ $zip = [IO.Compression.ZipFile]::OpenRead($destination)
+ try {
+ if ($zip.Entries.Count -ne $files.Count) { throw 'Unexpected archive entries.' }
+ foreach ($file in $files) {
+ $entry = $zip.GetEntry($file)
+ if (-not $entry) { throw "Missing archive file: $file" }
+ $stream = $entry.Open()
+ $buffer = [IO.MemoryStream]::new()
+ try {
+ $stream.CopyTo($buffer)
+ $expected = [Convert]::ToBase64String([IO.File]::ReadAllBytes((Join-Path $source $file)))
+ if ([Convert]::ToBase64String($buffer.ToArray()) -cne $expected) { throw "Stale archive file: $file" }
+ } finally { $stream.Dispose(); $buffer.Dispose() }
+ }
+ } finally { $zip.Dispose() }
+ Write-Host 'Toolkit ZIP matches all eight source files; sample is synthetic.'
+} else {
+ $null = [IO.Directory]::CreateDirectory((Split-Path $destination -Parent))
+ $stream = [IO.File]::Open($destination, [IO.FileMode]::Create)
+ $zip = [IO.Compression.ZipArchive]::new($stream, [IO.Compression.ZipArchiveMode]::Create)
+ try {
+ foreach ($file in $files) {
+ $entry = $zip.CreateEntry($file)
+ $entry.LastWriteTime = [datetimeoffset]'2000-01-01T00:00:00Z'
+ $entryStream = $entry.Open()
+ try {
+ $bytes = [IO.File]::ReadAllBytes((Join-Path $source $file))
+ $entryStream.Write($bytes, 0, $bytes.Length)
+ } finally { $entryStream.Dispose() }
+ }
+ } finally { $zip.Dispose(); $stream.Dispose() }
+ Write-Host "Packaged $destination"
+}
diff --git a/tools/microsoft-365-incident-triage-toolkit/Export-M365IncidentTriage.ps1 b/tools/microsoft-365-incident-triage-toolkit/Export-M365IncidentTriage.ps1
new file mode 100644
index 0000000..8ea2804
--- /dev/null
+++ b/tools/microsoft-365-incident-triage-toolkit/Export-M365IncidentTriage.ps1
@@ -0,0 +1,87 @@
+#requires -Version 7.5
+<#
+.SYNOPSIS
+Collect a read-only Microsoft 365 service-health snapshot and incident handoff.
+.DESCRIPTION
+Demo mode uses packaged synthetic data without Graph. Live mode requires an existing
+delegated Graph connection to the explicit tenant in the Global environment.
+Each run creates a new directory under OutputRoot. Incomplete collection writes the
+available evidence, then throws; pwsh -File returns a nonzero exit code.
+#>
+[CmdletBinding(DefaultParameterSetName = 'Live')]
+param(
+ [Parameter(Mandatory, ParameterSetName = 'Demo')][switch]$Demo,
+ [Parameter(Mandatory, ParameterSetName = 'Live')][guid]$TenantId,
+ [Parameter(Mandatory)][ValidatePattern('^[A-Za-z0-9][A-Za-z0-9_-]{0,59}$')][string]$IncidentId,
+ [Parameter(Mandatory)][ValidateScript({ -not [string]::IsNullOrWhiteSpace($_) })][ValidateLength(1, 2000)][string]$Symptom,
+ [Parameter(Mandatory)][ValidateScript({ -not [string]::IsNullOrWhiteSpace($_) })][ValidateLength(1, 2000)][string]$Impact,
+ [Parameter(Mandatory)][string]$FirstObservedUtc,
+ [ValidateRange(0, 168)][int]$LookBackHours = 24,
+ [ValidateNotNullOrEmpty()][string]$OutputRoot = (Join-Path ([Environment]::GetFolderPath('UserProfile')) 'm365-triage')
+)
+Set-StrictMode -Version Latest
+$ErrorActionPreference = 'Stop'
+Import-Module (Join-Path $PSScriptRoot 'M365IncidentTriage.psm1') -Force
+$first = [datetimeoffset]::ParseExact($FirstObservedUtc, "yyyy-MM-dd'T'HH:mm:ss'Z'",
+ [cultureinfo]::InvariantCulture, [Globalization.DateTimeStyles]::AssumeUniversal)
+$started = [datetimeoffset]::UtcNow
+$mode = 'Live'
+$graphVersion = $null
+if ($PSCmdlet.ParameterSetName -eq 'Demo') {
+ $mode = 'Demo'
+ $fixture = Get-Content -LiteralPath (Join-Path $PSScriptRoot 'demo-snapshot.json') -Raw |
+ ConvertFrom-Json -AsHashtable -DateKind String
+ $started = [datetimeoffset]::Parse($fixture.snapshotAtUtc, [cultureinfo]::InvariantCulture)
+ $tenantLabel = 'SYNTHETIC — no tenant'
+ $request = {
+ param($uri)
+ $resource = ([uri]$uri).Segments[-1]
+ if (-not $fixture.collections.Contains($resource)) { throw 'Unknown demo collection.' }
+ $fixture.collections[$resource]
+ }.GetNewClosure()
+} else {
+ Import-Module Microsoft.Graph.Authentication -ErrorAction Stop
+ Assert-TriageContext -Context (Get-MgContext) -TenantId $TenantId
+ $graphVersion = (Get-Module Microsoft.Graph.Authentication).Version.ToString()
+ $tenantLabel = $TenantId.ToString()
+ $request = {
+ param($uri)
+ Invoke-MgGraphRequest -Method GET -Uri $uri -OutputType Hashtable -ErrorAction Stop
+ }
+}
+if ($first -gt $started) { throw 'FirstObservedUtc must not be after the snapshot time (the demo uses 2026-09-14T16:30:00Z).' }
+$since = $first.AddHours(-$LookBackHours)
+$health = Read-TriageCollection -Resource healthOverviews -Request $request
+$issues = Read-TriageCollection -Resource issues -Request $request
+$status = if ($health.Status -eq 'Complete' -and $issues.Status -eq 'Complete') { 'Complete' } else { 'Incomplete' }
+$finished = if ($mode -eq 'Demo') { $started } else { [datetimeoffset]::UtcNow }
+$evidence = [ordered]@{
+ SchemaVersion = '1.0'
+ ToolkitVersion = '1.0.0'
+ Mode = $mode
+ TenantId = $tenantLabel
+ PowerShellVersion = $PSVersionTable.PSVersion.ToString()
+ GraphAuthenticationVersion = $graphVersion
+ StartedAtUtc = $started.ToUniversalTime().ToString('o')
+ FinishedAtUtc = $finished.ToUniversalTime().ToString('o')
+ Incident = [ordered]@{
+ IncidentId = $IncidentId; Symptom = $Symptom; Impact = $Impact
+ FirstObservedUtc = $first.ToUniversalTime().ToString('o')
+ }
+ IssuesSinceUtc = $since.ToUniversalTime().ToString('o')
+ CollectionStatus = $status
+ Collections = [ordered]@{ HealthOverviews = $health; Issues = $issues }
+ CandidateIssues = @(Select-TriageIssue -Issues $issues.Items -SinceUtc $since)
+}
+# Unique directories preserve previous evidence, even for repeated runs of the same incident.
+$root = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($OutputRoot)
+$null = [IO.Directory]::CreateDirectory($root)
+$runName = $IncidentId + '-' + [datetimeoffset]::UtcNow.ToString('yyyyMMddTHHmmssfffZ') + '-' + [guid]::NewGuid().ToString('N')
+$runDirectory = Join-Path $root $runName
+$null = New-Item -ItemType Directory -Path $runDirectory -ErrorAction Stop
+$evidence | ConvertTo-Json -Depth 20 | Set-Content -LiteralPath (Join-Path $runDirectory 'evidence.json') -Encoding utf8NoBOM
+ConvertTo-TriageReport -Evidence $evidence | Set-Content -LiteralPath (Join-Path $runDirectory 'report.md') -Encoding utf8NoBOM
+[pscustomobject]@{ CollectionStatus = $status; Mode = $mode; OutputDirectory = $runDirectory }
+if ($status -ne 'Complete') {
+ throw "Collection is incomplete. Review collection results in $runDirectory before using this evidence."
+}
diff --git a/tools/microsoft-365-incident-triage-toolkit/M365IncidentTriage.psm1 b/tools/microsoft-365-incident-triage-toolkit/M365IncidentTriage.psm1
new file mode 100644
index 0000000..6c7b661
--- /dev/null
+++ b/tools/microsoft-365-incident-triage-toolkit/M365IncidentTriage.psm1
@@ -0,0 +1,176 @@
+#requires -Version 7.5
+Set-StrictMode -Version Latest
+
+function Assert-TriageContext {
+ param($Context, [guid]$TenantId)
+ if (-not $Context -or $Context.AuthType -ne 'Delegated' -or
+ $Context.Environment -ne 'Global' -or
+ [string]$Context.TenantId -ne $TenantId.ToString() -or
+ @($Context.Scopes) -notcontains 'ServiceHealth.Read.All') {
+ throw 'Connect to the requested tenant in Global with delegated ServiceHealth.Read.All first.'
+ }
+}
+
+function Read-TriageCollection {
+ [CmdletBinding()]
+ param(
+ [Parameter(Mandatory)][ValidateSet('healthOverviews', 'issues')][string]$Resource,
+ [Parameter(Mandatory)][scriptblock]$Request,
+ [ValidateRange(1, 100)][int]$MaxPages = 100
+ )
+ $path = "/v1.0/admin/serviceAnnouncement/$Resource"
+ $fields = if ($Resource -eq 'healthOverviews') {
+ @('id', 'service', 'status')
+ } else {
+ @('id', 'title', 'service', 'status', 'classification', 'startDateTime',
+ 'endDateTime', 'lastModifiedDateTime', 'isResolved', 'impactDescription')
+ }
+ $next = 'https://graph.microsoft.com' + $path + '?$select=' + ($fields -join ',')
+ $seen = [System.Collections.Generic.HashSet[string]]::new([StringComparer]::Ordinal)
+ $items = [System.Collections.Generic.List[object]]::new()
+ $pages = 0
+ $stage = 'RequestFailed'
+ try {
+ while ($next) {
+ $stage = 'UnsafeContinuation'
+ $uri = [uri]$next
+ if (-not $uri.IsAbsoluteUri -or $uri.Scheme -ne 'https' -or
+ $uri.Host -ne 'graph.microsoft.com' -or $uri.Port -ne 443 -or
+ $uri.UserInfo -or $uri.Fragment -or $uri.AbsolutePath -cne $path) {
+ throw 'Continuation must stay on the same Graph collection.'
+ }
+ $stage = 'RepeatedContinuation'
+ if (-not $seen.Add($next)) { throw 'Repeated continuation.' }
+ $stage = 'PageLimit'
+ if ($pages -ge $MaxPages) { throw 'Page limit reached.' }
+ $stage = 'RequestFailed'
+ $page = & $Request $next
+ $stage = 'InvalidResponse'
+ if ($page -isnot [System.Collections.IDictionary] -or
+ -not $page.Contains('value') -or $page.value -isnot [array]) {
+ throw 'Expected an object containing a value array.'
+ }
+ # Validate a whole page before retaining it; never count a malformed page as complete.
+ $pageItems = [System.Collections.Generic.List[object]]::new()
+ foreach ($item in $page.value) {
+ $stage = 'InvalidItem'
+ if ($item -isnot [System.Collections.IDictionary]) { throw 'Expected an object.' }
+ foreach ($required in @('id', 'service', 'status')) {
+ if ([string]::IsNullOrWhiteSpace([string]$item[$required])) {
+ throw 'Missing a required property.'
+ }
+ }
+ if ($Resource -eq 'issues') {
+ if ($item.isResolved -isnot [bool]) { throw 'Missing resolution state.' }
+ foreach ($dateField in @('startDateTime', 'lastModifiedDateTime')) {
+ if ([string]::IsNullOrWhiteSpace([string]$item[$dateField])) { throw 'Missing date.' }
+ $null = [datetimeoffset]::Parse([string]$item[$dateField], [cultureinfo]::InvariantCulture)
+ }
+ }
+ $selected = [ordered]@{}
+ foreach ($field in $fields) { $selected[$field] = $item[$field] }
+ $pageItems.Add($selected)
+ }
+ foreach ($item in $pageItems) { $items.Add($item) }
+ $pages++
+ $stage = 'InvalidResponse'
+ $continuation = $page['@odata.nextLink']
+ if ($null -ne $continuation -and
+ ($continuation -isnot [string] -or [string]::IsNullOrWhiteSpace($continuation))) {
+ throw 'Invalid continuation value.'
+ }
+ $next = [string]$continuation
+ }
+ return [ordered]@{ Status = 'Complete'; Pages = $pages; FailureReason = $null; Items = $items.ToArray() }
+ } catch {
+ # Do not copy HTTP response bodies, tokens, or request URLs into an escalation bundle.
+ return [ordered]@{ Status = 'Incomplete'; Pages = $pages; FailureReason = $stage; Items = $items.ToArray() }
+ }
+}
+
+function Select-TriageIssue {
+ param([AllowEmptyCollection()][object[]]$Issues, [datetimeoffset]$SinceUtc)
+ foreach ($issue in $Issues) {
+ if (-not $issue.isResolved -or
+ [datetimeoffset]::Parse([string]$issue.lastModifiedDateTime, [cultureinfo]::InvariantCulture) -ge $SinceUtc) {
+ $issue
+ }
+ }
+}
+
+function ConvertTo-TriageText {
+ param([AllowNull()][object]$Value)
+ # Numeric entities prevent operator/API text from introducing Markdown or HTML structure.
+ $text = ([string]$Value -replace '[\r\n\t]+', ' ').Trim()
+ [regex]::Replace($text, '[&<>"''`*_|\[\]\\]', {
+ param($match)
+ '' + [int][char]$match.Value + ';'
+ })
+}
+
+function ConvertTo-TriageReport {
+ param([System.Collections.IDictionary]$Evidence)
+ $e = $Evidence
+ $lines = [System.Collections.Generic.List[string]]::new()
+ $lines.Add('# Microsoft 365 incident triage')
+ $lines.Add('')
+ if ($e.Mode -eq 'Demo') { $lines.Add('**SYNTHETIC DEMO — no tenant data or live requests.**'); $lines.Add('') }
+ $lines.Add('Collection: **' + $e.CollectionStatus + '**. This is collection status, not service health.')
+ $lines.Add('')
+ foreach ($field in @('IncidentId', 'Symptom', 'Impact', 'FirstObservedUtc')) {
+ $lines.Add('- ' + $field + ': ' + (ConvertTo-TriageText $e.Incident[$field]))
+ }
+ $lines.Add('- Tenant: ' + (ConvertTo-TriageText $e.TenantId))
+ $lines.Add('- Snapshot started (UTC): ' + $e.StartedAtUtc)
+ $lines.Add('- Snapshot finished (UTC): ' + $e.FinishedAtUtc)
+ $lines.Add('- Issue selection: unresolved OR last modified on/after ' + $e.IssuesSinceUtc)
+ $lines.Add('')
+ $lines.Add('## Collection results')
+ $lines.Add('')
+ $lines.Add('| Collection | Result | Pages | Retained items | Failure reason |')
+ $lines.Add('| --- | --- | --- | --- | --- |')
+ foreach ($name in @('HealthOverviews', 'Issues')) {
+ $c = $e.Collections[$name]
+ $lines.Add("| $name | $($c.Status) | $($c.Pages) | $(@($c.Items).Count) | $($c.FailureReason) |")
+ }
+ $lines.Add('')
+ $lines.Add('## Service health snapshot')
+ $lines.Add('')
+ $lines.Add('| Service | Reported status |')
+ $lines.Add('| --- | --- |')
+ foreach ($health in $e.Collections.HealthOverviews.Items) {
+ $lines.Add('| ' + (ConvertTo-TriageText $health.service) + ' | ' + (ConvertTo-TriageText $health.status) + ' |')
+ }
+ if (-not @($e.Collections.HealthOverviews.Items).Count) { $lines.Add('| No rows collected; check collection results | Unknown |') }
+ $lines.Add('')
+ $lines.Add('## Issues to review')
+ $lines.Add('')
+ $lines.Add('These are candidates for manual review. Their presence does not establish the cause of this incident.')
+ $lines.Add('')
+ foreach ($issue in $e.CandidateIssues) {
+ $lines.Add('### ' + (ConvertTo-TriageText $issue.id) + ': ' + (ConvertTo-TriageText $issue.title))
+ $lines.Add('')
+ foreach ($field in @('service', 'status', 'classification', 'isResolved', 'startDateTime', 'endDateTime', 'lastModifiedDateTime', 'impactDescription')) {
+ $lines.Add('- ' + $field + ': ' + (ConvertTo-TriageText $issue[$field]))
+ }
+ $lines.Add('')
+ }
+ if (-not @($e.CandidateIssues).Count) {
+ $lines.Add('No candidate issues in the collected rows. This does not establish that the service is healthy.')
+ $lines.Add('')
+ }
+ $lines.Add('## Handoff — complete before escalating')
+ $lines.Add('')
+ $lines.Add('- Confirmed observations and reproduction steps: [complete]')
+ $lines.Add('- Affected and unaffected users, clients, locations, and networks: [complete]')
+ $lines.Add('- Candidate Microsoft issue and symptom/time match: [complete; correlation unconfirmed]')
+ $lines.Add('- Checks performed, evidence references, and results: [complete]')
+ $lines.Add('- Changes made and verification/rollback status: [complete; this collector changes no tenant settings]')
+ $lines.Add('- Workaround and business impact: [complete]')
+ $lines.Add('- Escalation request, owner, and next update (UTC): [complete]')
+ $lines.Add('')
+ $lines.Add('Review and redact this report and evidence.json before sharing; neither is automatically anonymized.')
+ $lines -join "`n"
+}
+
+Export-ModuleMember -Function Assert-TriageContext, Read-TriageCollection, Select-TriageIssue, ConvertTo-TriageReport
diff --git a/tools/microsoft-365-incident-triage-toolkit/README.md b/tools/microsoft-365-incident-triage-toolkit/README.md
new file mode 100644
index 0000000..38998de
--- /dev/null
+++ b/tools/microsoft-365-incident-triage-toolkit/README.md
@@ -0,0 +1,95 @@
+# Microsoft 365 Incident Triage Toolkit
+
+Version 1.0.0. A read-only, interactive service-health collector for the Microsoft Graph Global environment. Tested offline on PowerShell 7.6.5 with synthetic fixtures and a mocked Graph module. Live tenant integration has not been tested.
+
+## Contents
+
+- `Export-M365IncidentTriage.ps1`: command-line entry point.
+- `M365IncidentTriage.psm1`: context checks, collection, selection, and report formatting.
+- `demo-snapshot.json`: fixed synthetic API responses, dated 2026-09-14.
+- `samples/report.md` and `samples/evidence.json`: generated synthetic output.
+- `escalation-template.md`: editable handoff checklist.
+- `tests/Test-M365IncidentTriage.ps1`: dependency-free offline regression tests.
+
+## Try the offline demo
+
+Use PowerShell 7.5 or later (`pwsh`), not Windows PowerShell 5.1. Extract the complete ZIP and open PowerShell in that directory. Review downloaded scripts before running them; follow your organization's script-signing/execution policy.
+
+```powershell
+$incident = @{
+ IncidentId = 'DEMO-INC-001'
+ Symptom = 'Outlook on the web loads slowly for a fictional pilot group.'
+ Impact = 'Six fictional users; email response work delayed.'
+ FirstObservedUtc = '2026-09-14T16:00:00Z'
+}
+./Export-M365IncidentTriage.ps1 -Demo @incident
+```
+
+Demo mode needs no Microsoft module, account, or network. It uses a fixed snapshot time of `2026-09-14T16:30:00Z`, so use the example timestamp. Every run creates a new directory under `$HOME/m365-triage`, even when the incident ID is reused. `-OutputRoot` overrides that location. Read `report.md`; use `evidence.json` for structured evidence. Neither file contains credentials. Real reports do contain your tenant ID, incident text, and selected service-health data and are not automatically anonymized.
+
+## Connect and collect live data
+
+The tenant must approve the delegated `ServiceHealth.Read.All` permission, which requires administrator consent. Use your organization's approved Graph application/account. The examples use the standard Graph PowerShell application; no app-only, scheduled, or sovereign-cloud mode is implemented.
+
+If needed, install the authentication module from your approved source. For an organization that permits PowerShell Gallery:
+
+```powershell
+Install-Module Microsoft.Graph.Authentication -Scope CurrentUser -Repository PSGallery
+```
+
+Connect in a new PowerShell process and collect:
+
+```powershell
+Import-Module Microsoft.Graph.Authentication
+$tenantId = Read-Host 'Tenant ID (GUID)'
+$connection = @{
+ TenantId = $tenantId
+ Scopes = 'ServiceHealth.Read.All'
+ ContextScope = 'Process'
+}
+Connect-MgGraph @connection -NoWelcome
+Get-MgContext | Select-Object TenantId, AuthType, Environment, Scopes
+
+$incident = @{
+ IncidentId = Read-Host 'Incident ID (letters, digits, hyphens, underscores; up to 60 characters)'
+ Symptom = Read-Host 'Observed symptom'
+ Impact = Read-Host 'Confirmed business impact and affected scope'
+ FirstObservedUtc = Read-Host 'First observed UTC (YYYY-MM-DDTHH:mm:ssZ)'
+}
+try {
+ ./Export-M365IncidentTriage.ps1 -TenantId $tenantId @incident -LookBackHours 24
+} finally {
+ Disconnect-MgGraph
+}
+```
+
+The collector itself does not connect or disconnect your session. It validates tenant ID, delegated authentication, Global environment, and the required scope before issuing GET requests. It does not require or enforce that the session has *only* that scope; use a fresh process and review the context. It neither installs modules nor changes tenant settings.
+
+## Collection and failure behavior
+
+Only these v1.0 collections are requested:
+
+- `/admin/serviceAnnouncement/healthOverviews`: ID, service, status.
+- `/admin/serviceAnnouncement/issues`: ID, title, service, status, classification, start/end/update times, resolution flag, impact description.
+
+The collector follows `@odata.nextLink` unchanged, checks the scheme/host/port/path, rejects loops, and stops after 100 pages per collection. The SDK supplies its standard retry behavior; no additional retry loop is layered on top. A final request failure produces an incomplete collection.
+
+JSON retains the selected properties from all successfully validated pages, including older resolved issues. Report candidates are unresolved issues **or** issues last modified on/after `FirstObservedUtc - LookBackHours`. This is a local selection rule, not a historical API query, root-cause match, or service filter. It cannot recover records the API no longer returns. No issue posts, sign-in logs, mailbox data, user inventory, or configuration are collected.
+
+`CollectionStatus: Complete` means both collections finished. `Incomplete` means at least one did not; review each collection's `Status`, `Pages`, `FailureReason`, and retained items. Available evidence is written before a terminating error is raised. A `pwsh -File` invocation returns nonzero for incomplete collection. Invalid input, context, or local write failures also terminate and may produce no complete bundle.
+
+Failure reasons: `RequestFailed` (check authentication, consent, connectivity, or throttling); `UnsafeContinuation`, `RepeatedContinuation`, `PageLimit` (collection stopped); `InvalidResponse`, `InvalidItem` (unexpected API data). Raw HTTP error bodies are deliberately excluded. Investigate a request failure in the approved administrative environment instead of pasting raw diagnostics into a public report.
+
+Service status strings are retained as reported. A complete empty collection or zero candidates is not proof of health. Compare candidates against symptom, time, service, and affected scope; check the current admin-center advisory before citing it.
+
+## Run the offline tests
+
+```powershell
+./tests/Test-M365IncidentTriage.ps1
+```
+
+The tests exercise pagination, partial failures, response validation, tenant/scope/cloud checks, selection, escaping, repeat-run preservation, and the live entry point using a local fake Graph module. Test files remain in the printed temporary directory for inspection. No real tenant is contacted. Real authentication, consent, tenant-specific permissions, and live SDK/API behavior require a separate tenant smoke test before operational adoption.
+
+Article: https://dleontev.com/blog/building-a-microsoft-365-incident-triage-toolkit-with-powershell
+
+API references: [health overviews](https://learn.microsoft.com/en-us/graph/api/serviceannouncement-list-healthoverviews?view=graph-rest-1.0), [issues](https://learn.microsoft.com/en-us/graph/api/serviceannouncement-list-issues?view=graph-rest-1.0), [authentication](https://learn.microsoft.com/en-us/powershell/microsoftgraph/authentication-commands?view=graph-powershell-1.0), [paging](https://learn.microsoft.com/en-us/graph/paging), [throttling](https://learn.microsoft.com/en-us/graph/throttling).
diff --git a/tools/microsoft-365-incident-triage-toolkit/demo-snapshot.json b/tools/microsoft-365-incident-triage-toolkit/demo-snapshot.json
new file mode 100644
index 0000000..92f824e
--- /dev/null
+++ b/tools/microsoft-365-incident-triage-toolkit/demo-snapshot.json
@@ -0,0 +1,53 @@
+{
+ "synthetic": true,
+ "snapshotAtUtc": "2026-09-14T16:30:00Z",
+ "collections": {
+ "healthOverviews": {
+ "value": [
+ { "id": "demo-exchange", "service": "Exchange Online", "status": "ServiceDegradation" },
+ { "id": "demo-teams", "service": "Microsoft Teams", "status": "ServiceOperational" },
+ { "id": "demo-sharepoint", "service": "SharePoint Online", "status": "ServiceOperational" }
+ ]
+ },
+ "issues": {
+ "value": [
+ {
+ "id": "DEMO-EX-001",
+ "title": "Synthetic example: delayed mailbox access",
+ "service": "Exchange Online",
+ "status": "ServiceDegradation",
+ "classification": "incident",
+ "startDateTime": "2026-09-14T15:45:00Z",
+ "endDateTime": null,
+ "lastModifiedDateTime": "2026-09-14T16:20:00Z",
+ "isResolved": false,
+ "impactDescription": "Fictional users may experience delayed mailbox access. This is not a real Microsoft advisory."
+ },
+ {
+ "id": "DEMO-TM-002",
+ "title": "Synthetic example: resolved meeting join delays",
+ "service": "Microsoft Teams",
+ "status": "ServiceRestored",
+ "classification": "advisory",
+ "startDateTime": "2026-09-13T17:00:00Z",
+ "endDateTime": "2026-09-13T18:00:00Z",
+ "lastModifiedDateTime": "2026-09-13T18:15:00Z",
+ "isResolved": true,
+ "impactDescription": "Fictional meeting join delays have ended; included to demonstrate recently updated resolved issues."
+ },
+ {
+ "id": "DEMO-SP-003",
+ "title": "Synthetic example: older resolved issue",
+ "service": "SharePoint Online",
+ "status": "ServiceRestored",
+ "classification": "advisory",
+ "startDateTime": "2026-09-01T10:00:00Z",
+ "endDateTime": "2026-09-01T11:00:00Z",
+ "lastModifiedDateTime": "2026-09-01T11:15:00Z",
+ "isResolved": true,
+ "impactDescription": "Outside the demo selection window; retained in evidence but omitted from report candidates."
+ }
+ ]
+ }
+ }
+}
diff --git a/tools/microsoft-365-incident-triage-toolkit/escalation-template.md b/tools/microsoft-365-incident-triage-toolkit/escalation-template.md
new file mode 100644
index 0000000..a612ac3
--- /dev/null
+++ b/tools/microsoft-365-incident-triage-toolkit/escalation-template.md
@@ -0,0 +1,35 @@
+# Microsoft 365 incident escalation
+
+Complete placeholders before sending. Use UTC timestamps. Keep personal information and detailed logs in the approved incident system; reference them here when possible.
+
+## Incident and impact
+
+- Incident ID: [ticket reference]
+- Service and failing user action: [specific symptom]
+- First observed (UTC): [YYYY-MM-DDTHH:mm:ssZ]
+- Affected population and business impact: [confirmed scope; distinguish estimates]
+- Unaffected comparison: [working user/client/location/network]
+- Current severity and owner: [per your incident process]
+
+## Evidence and working assessment
+
+- Snapshot start/end (UTC): [from evidence.json]
+- Collection status: [Complete/Incomplete; list failed collections]
+- Microsoft advisory candidate(s): [ID, service, last update, symptom/time match]
+- Correlation assessment: [confirmed observations; what remains unverified]
+- Reproduction steps and result: [client, version, time, action, observed error]
+- Checks performed: [time, action, result, evidence reference]
+- Recent changes and relevance: [known facts; avoid assuming causation]
+- Workaround and verification: [tested outcome and limits]
+- Changes made during response: [none, or change record plus rollback/verification status]
+
+## Requested action and next update
+
+- Escalation destination: [owning team or vendor]
+- Specific help requested: [decision or investigation needed]
+- Evidence attachments: [reviewed/redacted report, JSON, and approved log references]
+- Next action, owner, and deadline (UTC): [complete]
+- Next stakeholder update (UTC): [complete]
+- Closure verification: [affected user action succeeds; scope and observation period]
+
+Collection success does not establish service health or root cause. The generated files are not automatically anonymized; review them before attaching or sending.
diff --git a/tools/microsoft-365-incident-triage-toolkit/samples/evidence.json b/tools/microsoft-365-incident-triage-toolkit/samples/evidence.json
new file mode 100644
index 0000000..4554c64
--- /dev/null
+++ b/tools/microsoft-365-incident-triage-toolkit/samples/evidence.json
@@ -0,0 +1,111 @@
+{
+ "SchemaVersion": "1.0",
+ "ToolkitVersion": "1.0.0",
+ "Mode": "Demo",
+ "TenantId": "SYNTHETIC — no tenant",
+ "PowerShellVersion": "7.6.5",
+ "GraphAuthenticationVersion": null,
+ "StartedAtUtc": "2026-09-14T16:30:00.0000000+00:00",
+ "FinishedAtUtc": "2026-09-14T16:30:00.0000000+00:00",
+ "Incident": {
+ "IncidentId": "DEMO-INC-001",
+ "Symptom": "Outlook on the web loads slowly for a fictional pilot group.",
+ "Impact": "Six fictional users; email response work delayed.",
+ "FirstObservedUtc": "2026-09-14T16:00:00.0000000+00:00"
+ },
+ "IssuesSinceUtc": "2026-09-13T16:00:00.0000000+00:00",
+ "CollectionStatus": "Complete",
+ "Collections": {
+ "HealthOverviews": {
+ "Status": "Complete",
+ "Pages": 1,
+ "FailureReason": null,
+ "Items": [
+ {
+ "id": "demo-exchange",
+ "service": "Exchange Online",
+ "status": "ServiceDegradation"
+ },
+ {
+ "id": "demo-teams",
+ "service": "Microsoft Teams",
+ "status": "ServiceOperational"
+ },
+ {
+ "id": "demo-sharepoint",
+ "service": "SharePoint Online",
+ "status": "ServiceOperational"
+ }
+ ]
+ },
+ "Issues": {
+ "Status": "Complete",
+ "Pages": 1,
+ "FailureReason": null,
+ "Items": [
+ {
+ "id": "DEMO-EX-001",
+ "title": "Synthetic example: delayed mailbox access",
+ "service": "Exchange Online",
+ "status": "ServiceDegradation",
+ "classification": "incident",
+ "startDateTime": "2026-09-14T15:45:00Z",
+ "endDateTime": null,
+ "lastModifiedDateTime": "2026-09-14T16:20:00Z",
+ "isResolved": false,
+ "impactDescription": "Fictional users may experience delayed mailbox access. This is not a real Microsoft advisory."
+ },
+ {
+ "id": "DEMO-TM-002",
+ "title": "Synthetic example: resolved meeting join delays",
+ "service": "Microsoft Teams",
+ "status": "ServiceRestored",
+ "classification": "advisory",
+ "startDateTime": "2026-09-13T17:00:00Z",
+ "endDateTime": "2026-09-13T18:00:00Z",
+ "lastModifiedDateTime": "2026-09-13T18:15:00Z",
+ "isResolved": true,
+ "impactDescription": "Fictional meeting join delays have ended; included to demonstrate recently updated resolved issues."
+ },
+ {
+ "id": "DEMO-SP-003",
+ "title": "Synthetic example: older resolved issue",
+ "service": "SharePoint Online",
+ "status": "ServiceRestored",
+ "classification": "advisory",
+ "startDateTime": "2026-09-01T10:00:00Z",
+ "endDateTime": "2026-09-01T11:00:00Z",
+ "lastModifiedDateTime": "2026-09-01T11:15:00Z",
+ "isResolved": true,
+ "impactDescription": "Outside the demo selection window; retained in evidence but omitted from report candidates."
+ }
+ ]
+ }
+ },
+ "CandidateIssues": [
+ {
+ "id": "DEMO-EX-001",
+ "title": "Synthetic example: delayed mailbox access",
+ "service": "Exchange Online",
+ "status": "ServiceDegradation",
+ "classification": "incident",
+ "startDateTime": "2026-09-14T15:45:00Z",
+ "endDateTime": null,
+ "lastModifiedDateTime": "2026-09-14T16:20:00Z",
+ "isResolved": false,
+ "impactDescription": "Fictional users may experience delayed mailbox access. This is not a real Microsoft advisory."
+ },
+ {
+ "id": "DEMO-TM-002",
+ "title": "Synthetic example: resolved meeting join delays",
+ "service": "Microsoft Teams",
+ "status": "ServiceRestored",
+ "classification": "advisory",
+ "startDateTime": "2026-09-13T17:00:00Z",
+ "endDateTime": "2026-09-13T18:00:00Z",
+ "lastModifiedDateTime": "2026-09-13T18:15:00Z",
+ "isResolved": true,
+ "impactDescription": "Fictional meeting join delays have ended; included to demonstrate recently updated resolved issues."
+ }
+ ]
+}
diff --git a/tools/microsoft-365-incident-triage-toolkit/samples/report.md b/tools/microsoft-365-incident-triage-toolkit/samples/report.md
new file mode 100644
index 0000000..e56d7af
--- /dev/null
+++ b/tools/microsoft-365-incident-triage-toolkit/samples/report.md
@@ -0,0 +1,67 @@
+# Microsoft 365 incident triage
+
+**SYNTHETIC DEMO — no tenant data or live requests.**
+
+Collection: **Complete**. This is collection status, not service health.
+
+- IncidentId: DEMO-INC-001
+- Symptom: Outlook on the web loads slowly for a fictional pilot group.
+- Impact: Six fictional users; email response work delayed.
+- FirstObservedUtc: 2026-09-14T16:00:00.0000000+00:00
+- Tenant: SYNTHETIC — no tenant
+- Snapshot started (UTC): 2026-09-14T16:30:00.0000000+00:00
+- Snapshot finished (UTC): 2026-09-14T16:30:00.0000000+00:00
+- Issue selection: unresolved OR last modified on/after 2026-09-13T16:00:00.0000000+00:00
+
+## Collection results
+
+| Collection | Result | Pages | Retained items | Failure reason |
+| --- | --- | --- | --- | --- |
+| HealthOverviews | Complete | 1 | 3 | |
+| Issues | Complete | 1 | 3 | |
+
+## Service health snapshot
+
+| Service | Reported status |
+| --- | --- |
+| Exchange Online | ServiceDegradation |
+| Microsoft Teams | ServiceOperational |
+| SharePoint Online | ServiceOperational |
+
+## Issues to review
+
+These are candidates for manual review. Their presence does not establish the cause of this incident.
+
+### DEMO-EX-001: Synthetic example: delayed mailbox access
+
+- service: Exchange Online
+- status: ServiceDegradation
+- classification: incident
+- isResolved: False
+- startDateTime: 2026-09-14T15:45:00Z
+- endDateTime:
+- lastModifiedDateTime: 2026-09-14T16:20:00Z
+- impactDescription: Fictional users may experience delayed mailbox access. This is not a real Microsoft advisory.
+
+### DEMO-TM-002: Synthetic example: resolved meeting join delays
+
+- service: Microsoft Teams
+- status: ServiceRestored
+- classification: advisory
+- isResolved: True
+- startDateTime: 2026-09-13T17:00:00Z
+- endDateTime: 2026-09-13T18:00:00Z
+- lastModifiedDateTime: 2026-09-13T18:15:00Z
+- impactDescription: Fictional meeting join delays have ended; included to demonstrate recently updated resolved issues.
+
+## Handoff — complete before escalating
+
+- Confirmed observations and reproduction steps: [complete]
+- Affected and unaffected users, clients, locations, and networks: [complete]
+- Candidate Microsoft issue and symptom/time match: [complete; correlation unconfirmed]
+- Checks performed, evidence references, and results: [complete]
+- Changes made and verification/rollback status: [complete; this collector changes no tenant settings]
+- Workaround and business impact: [complete]
+- Escalation request, owner, and next update (UTC): [complete]
+
+Review and redact this report and evidence.json before sharing; neither is automatically anonymized.
diff --git a/tools/microsoft-365-incident-triage-toolkit/tests/Test-M365IncidentTriage.ps1 b/tools/microsoft-365-incident-triage-toolkit/tests/Test-M365IncidentTriage.ps1
new file mode 100644
index 0000000..4223523
--- /dev/null
+++ b/tools/microsoft-365-incident-triage-toolkit/tests/Test-M365IncidentTriage.ps1
@@ -0,0 +1,181 @@
+#requires -Version 7.5
+[CmdletBinding()]
+param([string]$OutputRoot = (Join-Path ([IO.Path]::GetTempPath()) ('triage-tests-' + [guid]::NewGuid().ToString('N'))))
+Set-StrictMode -Version Latest
+$ErrorActionPreference = 'Stop'
+$kit = Split-Path $PSScriptRoot -Parent
+Import-Module (Join-Path $kit 'M365IncidentTriage.psm1') -Force
+$null = [IO.Directory]::CreateDirectory($OutputRoot)
+$passed = 0
+function Assert($Condition, [string]$Message) { if (-not $Condition) { throw $Message } }
+function Test([string]$Name, [scriptblock]$Body) {
+ & $Body
+ $script:passed++
+ Write-Host "PASS $Name"
+}
+function Assert-Throws([scriptblock]$Body) {
+ $threw = $false
+ try { & $Body | Out-Null } catch { $threw = $true }
+ Assert $threw 'Expected a terminating error.'
+}
+$fixturePath = Join-Path $kit 'demo-snapshot.json'
+$fixture = Get-Content -LiteralPath $fixturePath -Raw | ConvertFrom-Json -AsHashtable -DateKind String
+$healthRow = $fixture.collections.healthOverviews.value[0]
+$baseUri = 'https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/healthOverviews'
+$page2 = $baseUri + '?$skiptoken=synthetic'
+
+Test 'Pagination follows an empty first page' {
+ $healthRow = $healthRow; $page2 = $page2
+ $calls = [Collections.Generic.List[string]]::new()
+ $request = {
+ param($uri)
+ $calls.Add($uri)
+ if ($uri -eq $page2) { return @{ value = @($healthRow) } }
+ @{ value = @(); '@odata.nextLink' = $page2 }
+ }.GetNewClosure()
+ $r = Read-TriageCollection healthOverviews $request
+ Assert ($r.Status -eq 'Complete' -and $r.Pages -eq 2 -and $r.Items.Count -eq 1) 'Lost a later page.'
+ Assert ($calls[1] -ceq $page2) 'Continuation was rebuilt rather than followed.'
+}
+Test 'A later request failure retains earlier evidence and marks it incomplete' {
+ $healthRow = $healthRow; $page2 = $page2
+ $request = {
+ param($uri)
+ if ($uri -eq $page2) { throw 'Synthetic HTTP failure; do not export this body.' }
+ @{ value = @($healthRow); '@odata.nextLink' = $page2 }
+ }.GetNewClosure()
+ $r = Read-TriageCollection healthOverviews $request
+ Assert ($r.Status -eq 'Incomplete' -and $r.Items.Count -eq 1 -and $r.FailureReason -eq 'RequestFailed') 'Partial failure was hidden.'
+}
+Test 'A foreign continuation is rejected before a request' {
+ $healthRow = $healthRow
+ $calls = [Collections.Generic.List[string]]::new()
+ $request = { param($uri); $calls.Add($uri); @{ value = @($healthRow); '@odata.nextLink' = 'https://example.org/collect' } }.GetNewClosure()
+ $r = Read-TriageCollection healthOverviews $request
+ Assert ($r.FailureReason -eq 'UnsafeContinuation' -and $calls.Count -eq 1) 'Requested a foreign host.'
+}
+Test 'Cross-resource, insecure, and credential-bearing continuations are rejected' {
+ foreach ($bad in @('https://graph.microsoft.com/v1.0/users',
+ 'http://graph.microsoft.com/v1.0/admin/serviceAnnouncement/healthOverviews',
+ 'https://user@graph.microsoft.com/v1.0/admin/serviceAnnouncement/healthOverviews')) {
+ $request = { param($uri); @{ value = @(); '@odata.nextLink' = $bad } }.GetNewClosure()
+ $r = Read-TriageCollection healthOverviews $request
+ Assert ($r.FailureReason -eq 'UnsafeContinuation') "Accepted $bad"
+ }
+}
+Test 'Repeated pages and page limits stop collection' {
+ $page2 = $page2
+ $request = { param($uri); @{ value = @(); '@odata.nextLink' = $page2 } }.GetNewClosure()
+ Assert ((Read-TriageCollection healthOverviews $request).FailureReason -eq 'RepeatedContinuation') 'Loop not detected.'
+ Assert ((Read-TriageCollection healthOverviews $request -MaxPages 1).FailureReason -eq 'PageLimit') 'Page limit ignored.'
+}
+Test 'Malformed responses cannot look like empty success' {
+ foreach ($badPage in @(@{}, @{value = $null}, @{value = 'invalid'}, @{value = @(@{id = 'x'})})) {
+ $request = { param($uri); $badPage }.GetNewClosure()
+ Assert ((Read-TriageCollection healthOverviews $request).Status -eq 'Incomplete') 'Malformed data treated as success.'
+ }
+}
+Test 'Missing issue state or date is incomplete' {
+ foreach ($property in @('isResolved', 'lastModifiedDateTime')) {
+ $row = $fixture.collections.issues.value[0].Clone()
+ $row.Remove($property)
+ $request = { param($uri); @{value = @($row)} }.GetNewClosure()
+ Assert ((Read-TriageCollection issues $request).FailureReason -eq 'InvalidItem') 'Invalid issue accepted.'
+ }
+}
+Test 'Selection retains open issues and recently updated resolved issues' {
+ $rows = @(Select-TriageIssue $fixture.collections.issues.value ([datetimeoffset]'2026-09-13T16:00:00Z'))
+ Assert ($rows.Count -eq 2 -and $rows.id -contains 'DEMO-TM-002' -and $rows.id -notcontains 'DEMO-SP-003') 'Incorrect date selection.'
+ $rows = @(Select-TriageIssue $fixture.collections.issues.value ([datetimeoffset]'2026-09-15T00:00:00Z'))
+ Assert ($rows.Count -eq 1 -and $rows[0].id -eq 'DEMO-EX-001') 'Old unresolved issue was dropped.'
+}
+Test 'Tenant, delegated scope, and cloud checks fail closed' {
+ $context = @{TenantId = '00000000-0000-0000-0000-000000000001'; AuthType = 'Delegated'; Environment = 'Global'; Scopes = @('ServiceHealth.Read.All')}
+ Assert-TriageContext $context ([guid]$context.TenantId)
+ Assert-Throws { Assert-TriageContext $null ([guid]$context.TenantId) }
+ foreach ($change in @(@{TenantId = '00000000-0000-0000-0000-000000000002'}, @{AuthType = 'AppOnly'}, @{Environment = 'USGov'}, @{Scopes = @('User.Read')})) {
+ $badContext = $context.Clone()
+ foreach ($key in $change.Keys) { $badContext[$key] = $change[$key] }
+ Assert-Throws { Assert-TriageContext $badContext ([guid]$context.TenantId) }
+ }
+}
+$demoParams = @{
+ Demo = $true; IncidentId = 'DEMO-INC-001'
+ Symptom = 'Outlook on the web loads slowly for a fictional pilot group.'
+ Impact = 'Six fictional users; email response work delayed.'
+ FirstObservedUtc = '2026-09-14T16:00:00Z'; OutputRoot = $OutputRoot
+}
+Test 'Demo runs offline and produces a labeled, parseable bundle' {
+ $run = & (Join-Path $kit 'Export-M365IncidentTriage.ps1') @demoParams
+ $e = Get-Content -LiteralPath (Join-Path $run.OutputDirectory 'evidence.json') -Raw | ConvertFrom-Json -AsHashtable -DateKind String
+ $report = Get-Content -LiteralPath (Join-Path $run.OutputDirectory 'report.md') -Raw
+ Assert ($e.Mode -eq 'Demo' -and $e.CollectionStatus -eq 'Complete' -and $e.CandidateIssues.Count -eq 2) 'Demo output is wrong.'
+ Assert ($report.Contains('SYNTHETIC DEMO') -and $report.Contains('DEMO-TM-002')) 'Missing synthetic label or candidate.'
+ $script:firstRun = $run.OutputDirectory
+}
+Test 'Repeat runs preserve prior evidence and escape report text' {
+ $before = (Get-FileHash -LiteralPath (Join-Path $firstRun 'evidence.json')).Hash
+ $params = $demoParams.Clone()
+ $params.Symptom = " | [click](https://example.org)`n# forged heading"
+ $run = & (Join-Path $kit 'Export-M365IncidentTriage.ps1') @params
+ $report = Get-Content -LiteralPath (Join-Path $run.OutputDirectory 'report.md') -Raw
+ Assert ($run.OutputDirectory -ne $firstRun -and $before -eq (Get-FileHash -LiteralPath (Join-Path $firstRun 'evidence.json')).Hash) 'Prior evidence overwritten.'
+ Assert (-not $report.Contains('