Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/cis/Test.CIS.M365.4.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Compliance policies are sets of rules and conditions that are used to evaluate t

The recommended state is **Mark devices with no compliance policy assigned as** **Not compliant**

This test runs the same check as [MT.1054](https://maester.dev/docs/tests/MT.1054). The benchmark's audit reads the Intune device management settings and verifies that `secureByDefault` is `true`, which is what MT.1054 checks. The default, **Compliant** (`secureByDefault` is `false`), fails.

#### Rationale

Implementing this setting is a first step in adopting compliance policies for devices. When used in together with Conditional Access policies the attack surface can be reduced by forcing an action to be taken for non-compliant devices.
Expand Down
36 changes: 5 additions & 31 deletions tests/cis/Test.CIS.M365.4.1.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
Devices without a compliance policy assigned should be marked "not compliant".
CIS Microsoft 365 Foundations Benchmark v7.0.0 (4.1, L1)

The benchmark's audit reads deviceManagement/settings and verifies that secureByDefault is True.
MT.1054 checks the same setting, so this test runs that check (Test-MtDeviceComplianceSettings).

.EXAMPLE
Test-MtCisDevicesWithoutCompliancePolicyMarked

Returns true if devices without a compliance policy assigned are marked "not compliant".

.LINK
https://maester.dev/docs/commands/Test-MtCisDevicesWithoutCompliancePolicyMarked
https://maester.dev/docs/tests/CIS.M365.4.1
#>
[MaesterTest(
Id = 'CIS.M365.4.1',
Expand All @@ -36,34 +39,5 @@
[OutputType([bool])]
param()

Write-Verbose 'Getting settings...'
$settings = Invoke-MtGraphRequest -RelativeUri "deviceManagement/settings"

Write-Verbose 'Executing checks'
$checkSecureByDefault = $settings | Where-Object { $_.secureByDefault -eq $true }

$testResult = (($checkSecureByDefault | Measure-Object).Count -ge 1)

if ($testResult) {
$testResultMarkdown = "Well done. Your tenant settings comply with CIS recommendations.`n`n%TestResult%"
}
else {
$testResultMarkdown = "Your tenant settings do not comply with CIS recommendations.`n`n%TestResult%"
}

$resultMd = "| Setting | Result |`n"
$resultMd += "| --- | --- |`n"

if ($checkSecureByDefault) {
$checkSecureByDefaultResult = '✅ Pass'
}
else {
$checkSecureByDefaultResult = '❌ Fail'
}

$resultMd += "| Mark devices with no compliance policy assigned as 'Not compliant' | $checkSecureByDefaultResult |`n"
$testResultMarkdown = $testResultMarkdown -replace '%TestResult%', $resultMd

Add-MtTestResultDetail -Result $testResultMarkdown
return $testResult
return Test-MtDeviceComplianceSettings
}
Loading