forked from mozziemozz/M365CallFlowVisualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInvoke-M365CFVConfigAudit.ps1
More file actions
605 lines (509 loc) · 23.4 KB
/
Invoke-M365CFVConfigAudit.ps1
File metadata and controls
605 lines (509 loc) · 23.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
<#
.SYNOPSIS
Audits Microsoft 365 Phone System configuration for common misconfigurations and best practice violations.
.DESCRIPTION
Author: Patrik Lleshaj (https://github.com/realgarit)
Version: 1.0.0
Changelog: .\Changelog.md
Scans all Auto Attendants, Call Queues, and Resource Accounts in the connected tenant
and checks for issues like missing agents, dead-end routes, orphaned resource accounts,
missing phone numbers, disabled users in queues, and more.
Outputs a health report to the console and optionally saves it as CSV and Markdown.
.PARAMETER CustomFilePath
Directory where the report files will be saved.
.PARAMETER ExportCsv
Export findings as a CSV file.
.PARAMETER ExportMarkdown
Export findings as a Markdown report.
.PARAMETER SaveSnapshot
Save a JSON snapshot of the current configuration for later diffing with Compare-M365CFVConfigSnapshot.ps1.
.EXAMPLE
.\Invoke-M365CFVConfigAudit.ps1
.EXAMPLE
.\Invoke-M365CFVConfigAudit.ps1 -ExportMarkdown -SaveSnapshot -CustomFilePath ".\Output\audit"
#>
#Requires -Modules @{ ModuleName = "MicrosoftTeams"; ModuleVersion = "5.0.0" }, "Microsoft.Graph.Users", "Microsoft.Graph.Groups"
[CmdletBinding()]
param(
[Parameter(Mandatory = $false)][String]$CustomFilePath = ".\Output\audit\$(Get-Date -Format 'yyyy-MM-dd')",
[Parameter(Mandatory = $false)][Switch]$ExportCsv,
[Parameter(Mandatory = $false)][Switch]$ExportMarkdown,
[Parameter(Mandatory = $false)][Switch]$SaveSnapshot
)
# Load shared functions
. .\Functions\Connect-M365CFV.ps1
. .\Functions\Get-AllVoiceAppsAndResourceAccounts.ps1
. .\Functions\Format-PhoneNumber.ps1
# Connect
. Connect-M365CFV
# Fetch all data
$CacheResults = $false
. Get-AllVoiceAppsAndResourceAccounts
# Build lookup tables
$allAutoAttendantIds = $allAutoAttendants.Identity
$allCallQueueIds = $allCallQueues.Identity
$resourceAccountLookup = @{}
foreach ($ra in $allResourceAccounts) {
$resourceAccountLookup[$ra.ObjectId] = $ra
}
# All voice app application instance IDs (for orphan detection)
$allAssociatedInstanceIds = @()
$allAssociatedInstanceIds += $allAutoAttendants.ApplicationInstances
$allAssociatedInstanceIds += $allCallQueues.ApplicationInstances
$allAssociatedInstanceIds = $allAssociatedInstanceIds | Sort-Object -Unique
# Resource accounts with phone numbers
$resourceAccountsWithPhone = $allResourceAccounts | Where-Object { $_.PhoneNumber }
# Findings collection
$findings = [System.Collections.ArrayList]::new()
function Add-Finding {
param(
[string]$Severity, # Critical, Warning, Info
[string]$Category,
[string]$ResourceType,
[string]$ResourceName,
[string]$ResourceId,
[string]$Description
)
[void]$findings.Add([PSCustomObject]@{
Severity = $Severity
Category = $Category
ResourceType = $ResourceType
ResourceName = $ResourceName
ResourceId = $ResourceId
Description = $Description
})
}
Write-Host "`nRunning configuration audit..." -ForegroundColor Cyan
# ========================================
# AUTO ATTENDANT CHECKS
# ========================================
foreach ($aa in $allAutoAttendants) {
$aaName = $aa.Name
$aaId = $aa.Identity
# Check: AA without any resource account
if (-not $aa.ApplicationInstances -or $aa.ApplicationInstances.Count -eq 0) {
# Check if it's nested somewhere
$isNested = $false
foreach ($otherAa in $allAutoAttendants) {
if ($otherAa.Identity -eq $aaId) { continue }
$callFlowJson = $otherAa | ConvertTo-Json -Depth 10
if ($callFlowJson -match $aaId) {
$isNested = $true
break
}
}
if (-not $isNested) {
Add-Finding -Severity "Warning" -Category "Orphaned" -ResourceType "Auto Attendant" `
-ResourceName $aaName -ResourceId $aaId `
-Description "No resource account assigned and not nested in any other voice app. This AA is unreachable."
}
}
# Check: AA has resource account but none have phone numbers (top-level check)
if ($aa.ApplicationInstances -and $aa.ApplicationInstances.Count -gt 0) {
$hasPhone = $false
foreach ($instanceId in $aa.ApplicationInstances) {
$ra = $resourceAccountLookup[$instanceId]
if ($ra -and $ra.PhoneNumber) {
$hasPhone = $true
break
}
}
# Only flag if it doesn't appear to be nested
if (-not $hasPhone) {
$isNested = $false
foreach ($otherAa in $allAutoAttendants) {
if ($otherAa.Identity -eq $aaId) { continue }
$callFlowJson = $otherAa | ConvertTo-Json -Depth 10
if ($callFlowJson -match $aaId) {
$isNested = $true
break
}
}
foreach ($cq in $allCallQueues) {
$callFlowJson = $cq | ConvertTo-Json -Depth 10
if ($callFlowJson -match $aaId) {
$isNested = $true
break
}
}
if (-not $isNested) {
Add-Finding -Severity "Critical" -Category "No Phone Number" -ResourceType "Auto Attendant" `
-ResourceName $aaName -ResourceId $aaId `
-Description "Top-level AA has resource account(s) but none have a phone number assigned. Callers can't reach this AA externally."
}
}
}
# Check: Default call flow disconnect without greeting
$defaultMenu = $aa.DefaultCallFlow.Menu
if ($defaultMenu) {
$allDisconnect = $true
foreach ($option in $defaultMenu.MenuOptions) {
if ($option.Action -ne "DisconnectCall") {
$allDisconnect = $false
break
}
}
if ($allDisconnect -and (-not $aa.DefaultCallFlow.Greetings -or $aa.DefaultCallFlow.Greetings.Count -eq 0)) {
Add-Finding -Severity "Warning" -Category "Dead End" -ResourceType "Auto Attendant" `
-ResourceName $aaName -ResourceId $aaId `
-Description "Default call flow disconnects callers without any greeting. Callers hear nothing before being disconnected."
}
}
# Check: No after-hours handling configured
$hasAfterHours = $false
if ($aa.CallHandlingAssociations) {
foreach ($assoc in $aa.CallHandlingAssociations) {
if ($assoc.Type -eq "AfterHours") {
$hasAfterHours = $true
break
}
}
}
if (-not $hasAfterHours) {
Add-Finding -Severity "Info" -Category "No After-Hours" -ResourceType "Auto Attendant" `
-ResourceName $aaName -ResourceId $aaId `
-Description "No after-hours call handling configured. This AA uses the same call flow 24/7."
}
# Check: No holiday handling configured
$hasHolidays = $false
if ($aa.CallHandlingAssociations) {
foreach ($assoc in $aa.CallHandlingAssociations) {
if ($assoc.Type -eq "Holiday") {
$hasHolidays = $true
break
}
}
}
if (-not $hasHolidays) {
Add-Finding -Severity "Info" -Category "No Holidays" -ResourceType "Auto Attendant" `
-ResourceName $aaName -ResourceId $aaId `
-Description "No holiday call handling configured."
}
# Check: Menu options that reference non-existent voice apps
if ($defaultMenu -and $defaultMenu.MenuOptions) {
foreach ($option in $defaultMenu.MenuOptions) {
if ($option.CallTarget -and $option.CallTarget.Id) {
$targetId = $option.CallTarget.Id
if ($option.CallTarget.Type -eq "ConfigurationEndpoint" -or $option.CallTarget.Type -eq "ApplicationEndpoint") {
if ($allAutoAttendantIds -notcontains $targetId -and $allCallQueueIds -notcontains $targetId) {
# Could be a resource account ID - check
$matchedRa = $resourceAccountLookup[$targetId]
if (-not $matchedRa) {
Add-Finding -Severity "Critical" -Category "Broken Reference" -ResourceType "Auto Attendant" `
-ResourceName $aaName -ResourceId $aaId `
-Description "Menu option references target '$targetId' which doesn't exist as a voice app or resource account."
}
}
}
}
}
}
}
# ========================================
# CALL QUEUE CHECKS
# ========================================
foreach ($cq in $allCallQueues) {
$cqName = $cq.Name
$cqId = $cq.Identity
# Check: CQ without any resource account
if (-not $cq.ApplicationInstances -or $cq.ApplicationInstances.Count -eq 0) {
$isNested = $false
foreach ($aa in $allAutoAttendants) {
$callFlowJson = $aa | ConvertTo-Json -Depth 10
if ($callFlowJson -match $cqId) {
$isNested = $true
break
}
}
if (-not $isNested) {
Add-Finding -Severity "Warning" -Category "Orphaned" -ResourceType "Call Queue" `
-ResourceName $cqName -ResourceId $cqId `
-Description "No resource account assigned and not nested in any other voice app. This CQ is unreachable."
}
}
# Check: CQ with no agents at all
$agentCount = 0
if ($cq.Agents) { $agentCount += $cq.Agents.Count }
if ($cq.DistributionLists) { $agentCount += $cq.DistributionLists.Count }
if ($cq.ChannelId) { $agentCount += 1 }
if ($agentCount -eq 0) {
Add-Finding -Severity "Critical" -Category "No Agents" -ResourceType "Call Queue" `
-ResourceName $cqName -ResourceId $cqId `
-Description "Call queue has no agents, distribution lists, or channels assigned. Calls will immediately hit the timeout/overflow action."
}
# Check: All individual agents opted out
if ($cq.Agents -and $cq.Agents.Count -gt 0 -and $cq.AllowOptOut -eq $true) {
$optedInCount = ($cq.Agents | Where-Object { $_.OptIn -eq $true }).Count
if ($optedInCount -eq 0) {
Add-Finding -Severity "Critical" -Category "All Agents Opted Out" -ResourceType "Call Queue" `
-ResourceName $cqName -ResourceId $cqId `
-Description "All $($cq.Agents.Count) agents have opted out. No one is receiving calls."
}
elseif ($optedInCount -eq 1) {
Add-Finding -Severity "Warning" -Category "Low Agent Count" -ResourceType "Call Queue" `
-ResourceName $cqName -ResourceId $cqId `
-Description "Only 1 out of $($cq.Agents.Count) agents is opted in."
}
}
# Check: Timeout action is Disconnect
if ($cq.TimeoutAction -eq "Disconnect") {
Add-Finding -Severity "Warning" -Category "Disconnect on Timeout" -ResourceType "Call Queue" `
-ResourceName $cqName -ResourceId $cqId `
-Description "Timeout action is set to Disconnect. Callers who wait longer than $($cq.TimeoutThreshold)s will be dropped without transfer or voicemail."
}
# Check: Overflow action is Disconnect
if ($cq.OverflowAction -eq "Disconnect") {
Add-Finding -Severity "Warning" -Category "Disconnect on Overflow" -ResourceType "Call Queue" `
-ResourceName $cqName -ResourceId $cqId `
-Description "Overflow action is set to Disconnect. Once $($cq.OverflowThreshold) callers are waiting, new callers are dropped."
}
# Check: Very short timeout
if ($cq.TimeoutThreshold -and $cq.TimeoutThreshold -le 30 -and $cq.TimeoutThreshold -gt 0) {
Add-Finding -Severity "Warning" -Category "Short Timeout" -ResourceType "Call Queue" `
-ResourceName $cqName -ResourceId $cqId `
-Description "Timeout threshold is only $($cq.TimeoutThreshold) seconds. Callers may be routed away before an agent can pick up."
}
# Check: Presence-based routing off with Longest Idle
if ($cq.RoutingMethod -eq "LongestIdle" -and $cq.PresenceBasedRouting -eq $false) {
Add-Finding -Severity "Info" -Category "Routing Config" -ResourceType "Call Queue" `
-ResourceName $cqName -ResourceId $cqId `
-Description "Longest Idle routing normally enables presence-based routing automatically. Current state shows PresenceBasedRouting=false, which is unusual."
}
# Check: Conference mode disabled
if ($cq.ConferenceMode -eq $false) {
Add-Finding -Severity "Info" -Category "Performance" -ResourceType "Call Queue" `
-ResourceName $cqName -ResourceId $cqId `
-Description "Conference mode is disabled. Enabling it reduces the time callers wait to connect to an agent after the agent accepts."
}
}
# ========================================
# RESOURCE ACCOUNT CHECKS
# ========================================
foreach ($ra in $allResourceAccounts) {
$raName = $ra.DisplayName
$raId = $ra.ObjectId
# Check: Resource account not associated with any voice app
if ($allAssociatedInstanceIds -notcontains $raId) {
Add-Finding -Severity "Warning" -Category "Unassigned" -ResourceType "Resource Account" `
-ResourceName "$raName ($($ra.UserPrincipalName))" -ResourceId $raId `
-Description "Resource account is not assigned to any Auto Attendant or Call Queue."
}
# Check: Resource account has phone number but is not associated
if ($ra.PhoneNumber -and $allAssociatedInstanceIds -notcontains $raId) {
$phoneNumber = Format-PhoneNumber -PhoneNumberId $ra.PhoneNumber
Add-Finding -Severity "Warning" -Category "Wasted Phone Number" -ResourceType "Resource Account" `
-ResourceName "$raName ($($ra.UserPrincipalName))" -ResourceId $raId `
-Description "Has phone number $phoneNumber assigned but is not linked to any voice app. This number is consuming a license but doing nothing."
}
}
# ========================================
# CROSS-REFERENCE CHECKS
# ========================================
# Check: Multiple AAs/CQs sharing the same resource account
$instanceToVoiceApp = @{}
foreach ($aa in $allAutoAttendants) {
foreach ($instanceId in $aa.ApplicationInstances) {
if (-not $instanceToVoiceApp.ContainsKey($instanceId)) {
$instanceToVoiceApp[$instanceId] = @()
}
$instanceToVoiceApp[$instanceId] += "AA: $($aa.Name)"
}
}
foreach ($cq in $allCallQueues) {
foreach ($instanceId in $cq.ApplicationInstances) {
if (-not $instanceToVoiceApp.ContainsKey($instanceId)) {
$instanceToVoiceApp[$instanceId] = @()
}
$instanceToVoiceApp[$instanceId] += "CQ: $($cq.Name)"
}
}
foreach ($instanceId in $instanceToVoiceApp.Keys) {
$apps = $instanceToVoiceApp[$instanceId]
if ($apps.Count -gt 1) {
$ra = $resourceAccountLookup[$instanceId]
$raDisplayName = if ($ra) { $ra.DisplayName } else { $instanceId }
Add-Finding -Severity "Warning" -Category "Shared Resource Account" -ResourceType "Resource Account" `
-ResourceName $raDisplayName -ResourceId $instanceId `
-Description "Shared across multiple voice apps: $($apps -join ', '). This can cause unexpected routing."
}
}
# ========================================
# SUMMARY
# ========================================
$criticalCount = ($findings | Where-Object { $_.Severity -eq "Critical" }).Count
$warningCount = ($findings | Where-Object { $_.Severity -eq "Warning" }).Count
$infoCount = ($findings | Where-Object { $_.Severity -eq "Info" }).Count
Write-Host "`n========================================" -ForegroundColor Cyan
Write-Host " CONFIGURATION AUDIT RESULTS" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host " Tenant: $((Get-CsTenant).DisplayName)"
Write-Host " Auto Attendants: $($allAutoAttendants.Count)"
Write-Host " Call Queues: $($allCallQueues.Count)"
Write-Host " Resource Accounts: $($allResourceAccounts.Count)"
Write-Host ""
if ($criticalCount -gt 0) {
Write-Host " CRITICAL: $criticalCount" -ForegroundColor Red
}
else {
Write-Host " CRITICAL: 0" -ForegroundColor Green
}
if ($warningCount -gt 0) {
Write-Host " WARNING: $warningCount" -ForegroundColor Yellow
}
else {
Write-Host " WARNING: 0" -ForegroundColor Green
}
Write-Host " INFO: $infoCount" -ForegroundColor Gray
Write-Host ""
# Health score: 100 minus penalties
$score = 100 - ($criticalCount * 15) - ($warningCount * 5) - ($infoCount * 1)
if ($score -lt 0) { $score = 0 }
$scoreColor = if ($score -ge 80) { "Green" } elseif ($score -ge 50) { "Yellow" } else { "Red" }
Write-Host " Health Score: $score / 100" -ForegroundColor $scoreColor
Write-Host "========================================`n" -ForegroundColor Cyan
# Print detailed findings
if ($findings.Count -gt 0) {
Write-Host "DETAILED FINDINGS:" -ForegroundColor Cyan
Write-Host ""
foreach ($severity in @("Critical", "Warning", "Info")) {
$sevFindings = $findings | Where-Object { $_.Severity -eq $severity }
if ($sevFindings.Count -eq 0) { continue }
$sevColor = switch ($severity) {
"Critical" { "Red" }
"Warning" { "Yellow" }
"Info" { "Gray" }
}
Write-Host "--- $($severity.ToUpper()) ---" -ForegroundColor $sevColor
foreach ($f in $sevFindings) {
Write-Host " [$($f.ResourceType)] $($f.ResourceName)" -ForegroundColor $sevColor
Write-Host " Category: $($f.Category)"
Write-Host " $($f.Description)"
Write-Host ""
}
}
}
else {
Write-Host "No issues found. Your configuration looks clean." -ForegroundColor Green
}
# ========================================
# EXPORTS
# ========================================
if ($ExportCsv -or $ExportMarkdown -or $SaveSnapshot) {
if (!(Test-Path -Path $CustomFilePath)) {
New-Item -Path $CustomFilePath -ItemType Directory | Out-Null
}
}
if ($ExportCsv) {
$csvPath = "$CustomFilePath\ConfigAudit_$(Get-Date -Format 'yyyyMMdd_HHmmss').csv"
$findings | Export-Csv -Path $csvPath -NoTypeInformation -Delimiter ";" -Encoding UTF8 -Force
Write-Host "CSV report saved to: $csvPath" -ForegroundColor Green
}
if ($ExportMarkdown) {
$mdPath = "$CustomFilePath\ConfigAudit_$(Get-Date -Format 'yyyyMMdd_HHmmss').md"
$mdContent = @"
# M365 Voice Configuration Audit Report
**Tenant:** $((Get-CsTenant).DisplayName)
**Date:** $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')
**Health Score:** $score / 100
## Summary
| Metric | Count |
|--------|-------|
| Auto Attendants | $($allAutoAttendants.Count) |
| Call Queues | $($allCallQueues.Count) |
| Resource Accounts | $($allResourceAccounts.Count) |
| Critical Issues | $criticalCount |
| Warnings | $warningCount |
| Info | $infoCount |
## Findings
"@
foreach ($severity in @("Critical", "Warning", "Info")) {
$sevFindings = $findings | Where-Object { $_.Severity -eq $severity }
if ($sevFindings.Count -eq 0) { continue }
$emoji = switch ($severity) {
"Critical" { "!!" }
"Warning" { "!" }
"Info" { "i" }
}
$mdContent += "`n### $severity ($($sevFindings.Count))`n`n"
foreach ($f in $sevFindings) {
$mdContent += "- **[$emoji] [$($f.ResourceType)] $($f.ResourceName)**`n"
$mdContent += " - Category: $($f.Category)`n"
$mdContent += " - $($f.Description)`n`n"
}
}
$mdContent += "`n---`n*Generated by M365 Call Flow Visualizer Config Audit*`n"
Set-Content -Path $mdPath -Value $mdContent -Encoding UTF8 -Force
Write-Host "Markdown report saved to: $mdPath" -ForegroundColor Green
}
# ========================================
# SNAPSHOT EXPORT (for diff comparison)
# ========================================
if ($SaveSnapshot) {
$snapshot = [PSCustomObject]@{
Timestamp = (Get-Date -Format 'o')
TenantName = (Get-CsTenant).DisplayName
TenantId = (Get-CsTenant).TenantId
AutoAttendants = $allAutoAttendants | ForEach-Object {
[PSCustomObject]@{
Identity = $_.Identity
Name = $_.Name
LanguageId = $_.LanguageId
TimeZoneId = $_.TimeZoneId
VoiceResponseEnabled = $_.VoiceResponseEnabled
VoiceId = $_.VoiceId
Operator = $_.Operator
DefaultCallFlow = $_.DefaultCallFlow
CallFlows = $_.CallFlows
Schedules = $_.Schedules
CallHandlingAssociations = $_.CallHandlingAssociations
DialByNameResourceId = $_.DialByNameResourceId
DirectoryLookupScope = $_.DirectoryLookupScope
ApplicationInstances = $_.ApplicationInstances
}
}
CallQueues = $allCallQueues | ForEach-Object {
[PSCustomObject]@{
Identity = $_.Identity
Name = $_.Name
RoutingMethod = $_.RoutingMethod
PresenceBasedRouting = $_.PresenceBasedRouting
ConferenceMode = $_.ConferenceMode
AllowOptOut = $_.AllowOptOut
AgentAlertTime = $_.AgentAlertTime
LanguageId = $_.LanguageId
OverflowThreshold = $_.OverflowThreshold
OverflowAction = $_.OverflowAction
OverflowActionTarget = $_.OverflowActionTarget
TimeoutThreshold = $_.TimeoutThreshold
TimeoutAction = $_.TimeoutAction
TimeoutActionTarget = $_.TimeoutActionTarget
Agents = $_.Agents | ForEach-Object {
[PSCustomObject]@{
ObjectId = $_.ObjectId
OptIn = $_.OptIn
}
}
DistributionLists = $_.DistributionLists
ChannelId = $_.ChannelId
ApplicationInstances = $_.ApplicationInstances
IsCallbackEnabled = $_.IsCallbackEnabled
UseDefaultMusicOnHold = $_.UseDefaultMusicOnHold
MusicOnHoldAudioFileId = $_.MusicOnHoldAudioFileId
}
}
ResourceAccounts = $allResourceAccounts | ForEach-Object {
[PSCustomObject]@{
ObjectId = $_.ObjectId
DisplayName = $_.DisplayName
UserPrincipalName = $_.UserPrincipalName
ApplicationId = $_.ApplicationId
PhoneNumber = $_.PhoneNumber
}
}
}
$snapshotPath = "$CustomFilePath\ConfigSnapshot_$(Get-Date -Format 'yyyyMMdd_HHmmss').json"
$snapshot | ConvertTo-Json -Depth 20 | Set-Content -Path $snapshotPath -Encoding UTF8 -Force
Write-Host "Configuration snapshot saved to: $snapshotPath" -ForegroundColor Green
Write-Host "Use Compare-M365CFVConfigSnapshot.ps1 to diff two snapshots." -ForegroundColor Cyan
}