Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,35 @@ Describe 'Test-MtMobileThreatDefenseConnectors' {
$script:Result | Should -BeLike '*No heartbeat has been received*'
}

It 'Asks for a MAM enrolment instead of more setup when Windows MAM is already on' {
# Measured in #2595: with the toggle on, the connector still reports notSetUp and no
# heartbeat until the first Windows MAM user enrols. The verdict must not move.
$script:Connector.partnerState = 'notSetUp'
$script:Connector.lastHeartbeatDateTime = '0001-01-01T00:00:00Z'
$script:Connector | Add-Member -NotePropertyName windowsMobileApplicationManagementEnabled -NotePropertyValue $true

Test-MtMobileThreatDefenseConnectors | Should -BeFalse
$script:Result | Should -BeLike '*first Windows MAM user enrols*'
$script:Result | Should -BeLike '*device threat messages are blocked*'
$script:Result | Should -Not -BeLike '*verify that the partner can communicate with Intune*'
$script:Result | Should -Not -BeLike '*Complete setup in Intune and with the partner*'
}

It 'Keeps the generic setup reason when <Case>' -ForEach @(
@{ Case = 'Windows MAM is off'; Id = 'c2b688fe-48c0-464b-a89c-67041aa8fcb2'; MamEnabled = $false }
@{ Case = 'another connector has MAM on'; Id = 'fc780465-2017-40d4-a0c5-307022471b92'; MamEnabled = $true }
) {
# Both guards matter: the reason is anchored on this connector's ID and on its own toggle,
# so neither one alone can swallow the generic explanation.
$script:Connector.id = $Id
$script:Connector.partnerState = 'notSetUp'
$script:Connector | Add-Member -NotePropertyName windowsMobileApplicationManagementEnabled -NotePropertyValue $MamEnabled

Test-MtMobileThreatDefenseConnectors | Should -BeFalse
$script:Result | Should -BeLike '*Complete setup in Intune and with the partner*'
$script:Result | Should -Not -BeLike '*first Windows MAM user enrols*'
}

It 'Explains a stale heartbeat' {
$script:Connector.lastHeartbeatDateTime = '2026-11-05T12:00:00Z'

Expand Down Expand Up @@ -155,6 +184,23 @@ Describe 'MT.1098 native engine results' {
$rows[0].ResultDetail.TestResult | Should -BeLike '*Never received*'
}

It 'Records the Windows MAM wait as Failed with the enrolment reason through the engine' {
Mock -ModuleName Maester Invoke-MtGraphRequest {
[pscustomobject]@{
id = 'c2b688fe-48c0-464b-a89c-67041aa8fcb2'
partnerState = 'notSetUp'
lastHeartbeatDateTime = '0001-01-01T00:00:00Z'
windowsMobileApplicationManagementEnabled = $true
}
}

$rows = @(Invoke-MtTest -Id 'MT.1098' -Config $script:config)
$rows | Should -HaveCount 1
$rows[0].Result | Should -Be 'Failed'
$rows[0].ResultDetail.TestResult | Should -BeLike '*first Windows MAM user enrols*'
$rows[0].ResultDetail.TestResult | Should -BeLike '*Never received*'
}

It 'Records the no-connectors case as Skipped through the engine' {
Mock -ModuleName Maester Invoke-MtGraphRequest { @() }

Expand Down
2 changes: 1 addition & 1 deletion tests/maester/intune/Test.MT.1098.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ This test verifies the health of Intune Mobile Threat Defense Connectors, includ

Each connector must be enabled and have a heartbeat in the last 48 hours. The result table explains unhealthy states and reports a missing or year-1 heartbeat as **Never received**.

A connector in `notSetUp` has not completed setup and blocks device threat messages. A connector in `available` has completed setup but needs a platform toggle enabled. Neither state satisfies this health check. An `unresponsive` connector needs attention because Intune ignores its compliance state once the configured unresponsiveness threshold is reached.
A connector in `notSetUp` has not completed setup and blocks device threat messages. The **Windows Security Center** connector is a special case noted in the Intune admin center: with **Connect Windows devices for MAM** already on, it stays in `notSetUp` with no heartbeat until the first Windows MAM user enrols, so its Reason asks for that enrolment rather than for more setup. A connector in `available` has completed setup but needs a platform toggle enabled. Neither state satisfies this health check. An `unresponsive` connector needs attention because Intune ignores its compliance state once the configured unresponsiveness threshold is reached.

#### Remediation action

Expand Down
26 changes: 23 additions & 3 deletions tests/maester/intune/Test.MT.1098.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
Service = 'Graph',
License = 'INTUNE_A',
Author = 'nicolonsky',
Contributor = ('Mynster9361', 'FiraSenax')
Contributor = ('Mynster9361', 'FiraSenax', 'julien-ly', 'earbona23')
)]
[CmdletBinding()]
[OutputType([bool])]
Expand Down Expand Up @@ -78,10 +78,26 @@
$connectorName = $connector.id
}

# The Windows Security Center connector reports 'notSetUp' with no heartbeat until the
# first Windows MAM user enrols, even with its own toggle already on (measured on a lab
# tenant in #2595; the Intune admin center says the status changes within 30 minutes of
# that enrolment). The verdict stays a failure, because Microsoft documents 'notSetUp' as
# blocking device threat messages whatever the cause. What changes is the Reason: without
# this, the row sends the operator back to the partner to finish a setup that is done.
$awaitingWindowsMamEnrolment = $connector.id -eq 'c2b688fe-48c0-464b-a89c-67041aa8fcb2' -and
$connector.windowsMobileApplicationManagementEnabled -and
$connector.partnerState -eq 'notSetUp'

$isConnected = $connector.partnerState -eq 'enabled'
$reasons = @(switch ($connector.partnerState) {
'enabled' { break }
'notSetUp' { 'Setup is incomplete; device threat messages are blocked. Complete setup in Intune and with the partner, or remove an unused connector.' }
'notSetUp' {
if ($awaitingWindowsMamEnrolment) {
'Connect Windows devices for MAM is on for this connector, so it stays in notSetUp until the first Windows MAM user enrols; device threat messages are blocked until then. Enrol a MAM user, or remove the connector if Windows MAM is not in use.'
} else {
'Setup is incomplete; device threat messages are blocked. Complete setup in Intune and with the partner, or remove an unused connector.'
}
}
'unavailable' { 'The connector is deprovisioned; device threat messages are blocked. Ask the MTD partner to provision it again.' }
'available' { 'Setup is complete. Turn on a platform toggle to enable the connector.' }
'unresponsive' { 'The connector is unresponsive. After its configured unresponsiveness threshold, Intune ignores its compliance state. Check the partner service and connectivity.' }
Expand All @@ -93,7 +109,11 @@
if ($heartbeat.Year -eq 1) {
$heartbeatDisplay = 'Never received'
$syncIsRecent = $false
$reasons += 'No heartbeat has been received. Complete setup and verify that the partner can communicate with Intune.'
$reasons += if ($awaitingWindowsMamEnrolment) {
'No heartbeat arrives before that first enrolment.'
} else {
'No heartbeat has been received. Complete setup and verify that the partner can communicate with Intune.'
}
} else {
$heartbeatDisplay = [string]$connector.lastHeartbeatDateTime
# At most one completed day since the heartbeat, so less than 48 hours.
Expand Down
Loading