-
Notifications
You must be signed in to change notification settings - Fork 234
Expand file tree
/
Copy pathTest-MtCisAttachmentFilter.ps1
More file actions
74 lines (58 loc) · 2.24 KB
/
Test-MtCisAttachmentFilter.ps1
File metadata and controls
74 lines (58 loc) · 2.24 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
function Test-MtCisAttachmentFilter {
<#
.SYNOPSIS
Checks if the default common attachment types filter is enabled
.DESCRIPTION
The common attachment types filter should be enabled
CIS Microsoft 365 Foundations Benchmark v6.0.1
.EXAMPLE
Test-MtCisAttachmentFilter
Returns true if the common attachment types filter is enabled.
.LINK
https://maester.dev/docs/commands/Test-MtCisAttachmentFilter
#>
[CmdletBinding()]
[OutputType([bool])]
param()
if (!(Test-MtConnection ExchangeOnline)) {
Add-MtTestResultDetail -SkippedBecause NotConnectedExchange
return $null
}
elseif (!(Test-MtConnection SecurityCompliance)) {
Add-MtTestResultDetail -SkippedBecause NotConnectedSecurityCompliance
return $null
}
try {
Write-Verbose "Getting Malware Filter Policy..."
$policies = Get-MtExo -Request MalwareFilterPolicy
# We grab the default policy
$policy = $policies | Where-Object { $_.IsDefault -eq $true }
Write-Verbose "Executing checks"
$fileFilter = $policy | Where-Object {
$_.EnableFileFilter -match "True"
}
$testResult = ($fileFilter | Measure-Object).Count -ge 1
$portalLink = "https://security.microsoft.com/presetSecurityPolicies"
if ($testResult) {
$testResultMarkdown = "Well done. Your tenants default malware filter policy has the common attachment file filter enabled ($portalLink).`n`n%TestResult%"
}
else {
$testResultMarkdown = "Your tenants default malware filter policy does not have the common attachment file filter enabled ($portalLink).`n`n%TestResult%"
}
$resultMd = "| Policy | Result |`n"
$resultMd += "| --- | --- |`n"
if ($testResult) {
$Result = "✅ Pass"
}
else {
$Result = "❌ Fail"
}
$resultMd += "| EnableFileFilter | $Result |`n"
$testResultMarkdown = $testResultMarkdown -replace "%TestResult%", $resultMd
Add-MtTestResultDetail -Result $testResultMarkdown
return $testResult
} catch {
Add-MtTestResultDetail -SkippedBecause Error -SkippedError $_
return $null
}
}