-
Notifications
You must be signed in to change notification settings - Fork 234
Expand file tree
/
Copy pathTest-MtCisAuditLogSearch.ps1
More file actions
58 lines (48 loc) · 1.74 KB
/
Test-MtCisAuditLogSearch.ps1
File metadata and controls
58 lines (48 loc) · 1.74 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
function Test-MtCisAuditLogSearch {
<#
.SYNOPSIS
Checks if audit log search is enabled
.DESCRIPTION
Microsoft 365 audit log search should be enabled
CIS Microsoft 365 Foundations Benchmark v6.0.1
.EXAMPLE
Test-MtCisAuditLogSearch
Returns true if audit log search is enabled
.LINK
https://maester.dev/docs/commands/Test-MtCisAuditLogSearch
#>
[CmdletBinding()]
[OutputType([bool])]
param()
if (!(Test-MtConnection ExchangeOnline)) {
Add-MtTestResultDetail -SkippedBecause NotConnectedExchange
return $null
}
try {
Write-Verbose 'Get audit log search status'
$auditLogSearch = Get-AdminAuditLogConfig
if ($auditLogSearch | Where-Object { $_.UnifiedAuditLogIngestionEnabled -ne 'True' }) {
$testResult = $false
$testResultMarkdown = "Your tenant does not have audit log search enabled:`n`n%TestResult%"
} else {
$testResult = $true
$testResultMarkdown = "Well done. Your tenant has audit log search enabled:`n`n%TestResult%"
}
$resultMd = "| Audit Log | Status |`n"
$resultMd += "| --- | --- |`n"
foreach ($item in $auditLogSearch) {
if ($item.UnifiedAuditLogIngestionEnabled) {
$itemResult = '✅ Enabled'
} else {
$itemResult = '❌ Disabled'
}
$resultMd += "| $($item.Name) | $($itemResult) |`n"
}
$testResultMarkdown = $testResultMarkdown -replace '%TestResult%', $resultMd
Add-MtTestResultDetail -Result $testResultMarkdown
return $testResult
} catch {
Add-MtTestResultDetail -SkippedBecause Error -SkippedError $_
return $null
}
}