-
Notifications
You must be signed in to change notification settings - Fork 218
Adding Microsoft Intune Checks #1327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds comprehensive Microsoft Intune health checks and monitoring capabilities to the Maester framework. It introduces license validation for Intune and implements 16 new security and operational checks covering device enrollment policies, certificate management, connector health, and platform configurations.
Key changes:
- Added Intune license detection in
Get-MtLicenseInformationwith support for multiple Intune service plan SKUs - Implemented 16 new test functions covering Apple/Android integrations, certificate connectors, compliance settings, and administrative policies
- Added
DeviceManagementRBAC.Read.Allpermission requirement for RBAC group protection checks
Reviewed Changes
Copilot reviewed 43 out of 43 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| website/docs/sections/permissions.md | Added DeviceManagementRBAC.Read.All permission |
| tests/maester-config.json | Added metadata for 16 new Intune checks (MT.1090-MT.1105) |
| tests/Maester/Intune/Test-MtIntunePlatform.Tests.ps1 | Added 6 new platform-level Intune tests |
| tests/Maester/Intune/Test-MtIntuneConnectorHealth.Tests.ps1 | New file with 5 connector health validation tests |
| tests/Maester/Entra/Test-MtEntraDeviceRegistrationPolicy.Tests.ps1 | Consolidated device registration and local admin tests |
| powershell/public/maester/intune/*.ps1 | Implemented 13 new test functions with license checking |
| powershell/public/maester/entra/*.ps1 | Added 2 device registration local admin validation functions |
| powershell/public/Get-MtLicenseInformation.ps1 | Added Intune license detection support |
| powershell/public/Get-MtGraphScope.ps1 | Added DeviceManagementRBAC.Read.All scope |
| powershell/public/Add-MtTestResultDetail.ps1 | Added NotLicensedIntune skip reason |
| powershell/internal/Get-MtSkippedReason.ps1 | Added Intune licensing message |
| powershell/Maester.psd1 | Exported 13 new test functions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
powershell/public/maester/intune/Test-MtCertificateConnectors.md
Outdated
Show resolved
Hide resolved
powershell/public/maester/intune/Test-MtIntuneDiagnosticSettings.md
Outdated
Show resolved
Hide resolved
powershell/public/maester/intune/Test-MtIntuneDiagnosticSettings.ps1
Outdated
Show resolved
Hide resolved
powershell/public/maester/intune/Test-MtFeatureUpdatePolicy.ps1
Outdated
Show resolved
Hide resolved
powershell/public/maester/intune/Test-MtCertificateConnectors.ps1
Outdated
Show resolved
Hide resolved
powershell/public/maester/intune/Test-MtOperationApprovalPolicies.md
Outdated
Show resolved
Hide resolved
powershell/public/maester/intune/Test-MtApplePushNotificationCertificate.md
Outdated
Show resolved
Hide resolved
powershell/public/maester/intune/Test-MtAndroidEnterpriseConnection.ps1
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 43 out of 43 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
powershell/public/maester/intune/Test-MtIntuneRbacGroupsProtected.ps1
Outdated
Show resolved
Hide resolved
powershell/public/maester/intune/Test-MtAppleVolumePurchaseProgramToken.md
Outdated
Show resolved
Hide resolved
powershell/public/maester/intune/Test-MtCertificateConnectors.ps1
Outdated
Show resolved
Hide resolved
powershell/public/maester/intune/Test-MtApplePushNotificationCertificate.ps1
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 43 out of 43 changed files in this pull request and generated 13 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
powershell/public/maester/intune/Test-MtTenantCustomization.ps1
Outdated
Show resolved
Hide resolved
tests/Maester/Entra/Test-MtEntraDeviceRegistrationPolicy.Tests.ps1
Outdated
Show resolved
Hide resolved
powershell/public/maester/intune/Test-MtTenantCustomization.ps1
Outdated
Show resolved
Hide resolved
powershell/public/maester/intune/Test-MtAppleVolumePurchaseProgramToken.ps1
Show resolved
Hide resolved
powershell/public/maester/intune/Test-MtAppleAutomatedDeviceEnrollmentToken.ps1
Show resolved
Hide resolved
powershell/public/maester/intune/Test-MtAppleVolumePurchaseProgramToken.ps1
Outdated
Show resolved
Hide resolved
powershell/public/maester/intune/Test-MtAppleAutomatedDeviceEnrollmentToken.ps1
Show resolved
Hide resolved
powershell/public/maester/intune/Test-MtMobileThreatDefenseConnectors.ps1
Show resolved
Hide resolved
|
Thank you @nicolonsky for this submission. I will review this over the weekend |
merill
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicolonsky this is amazing. Thank you for all the tests you are contributing.
In my tenant, which has intune license but not much configured a lot of the tests are erroring out.
Please see comments.
Thanks
| <# | ||
| .SYNOPSIS | ||
| Check the validity of the Apple Automated Device Enrollment (ADE) token for Intune. | ||
| .DESCRIPTION | ||
| The Apple Automated Device Enrollment (ADE) token is required to synchronize Apple devices with Microsoft Intune. This command checks if the ADE token is valid and not expired. | ||
|
|
||
| .EXAMPLE | ||
| Test-MtAppleAutomatedDeviceEnrollmentToken | ||
|
|
||
| Returns true if the ADE token is valid for more than 30 days, false if it is expired or expiring soon. | ||
|
|
||
| .LINK | ||
| https://maester.dev/docs/commands/Test-MtAppleAutomatedDeviceEnrollmentToken | ||
| #> | ||
| function Test-MtAppleAutomatedDeviceEnrollmentToken { | ||
| [CmdletBinding()] | ||
| [OutputType([bool])] | ||
| param() | ||
|
|
||
| if (-not (Get-MtLicenseInformation -Product Intune)) { | ||
| Add-MtTestResultDetail -SkippedBecause NotLicensedIntune | ||
| return $null | ||
| } | ||
|
|
||
| try { | ||
| Write-Verbose 'Retrieving Apple Automated Device Enrollment token status...' | ||
| $expirationThresholdDays = 30 | ||
| $automatedDeviceEnrollmentTokens = @(Invoke-MtGraphRequest -RelativeUri 'deviceManagement/depOnboardingSettings' -ApiVersion beta) | ||
|
|
||
| $testResultMarkdown = "Intune Automated Device Enrollment Token Status:`n" | ||
| $testResultMarkdown += "| Name | TokenExpirationDateTime | LastSuccessfulSyncDateTime | LastSyncErrorCode |`n" | ||
| $testResultMarkdown += "| --- | --- | --- | --- |`n" | ||
|
|
||
| $healthStatus = foreach ($token in $automatedDeviceEnrollmentTokens) { | ||
| $expiresInDays = [System.Math]::Ceiling(([datetime]$token.tokenExpirationDateTime - (Get-Date)).TotalDays) | ||
| $lastSyncDiffDays = [System.Math]::Floor(((Get-Date) - [datetime]$token.lastSuccessfulSyncDateTime).TotalDays) | ||
| $testResultMarkdown += "| $($token.tokenName) | $($token.tokenExpirationDateTime) | $($token.lastSuccessfulSyncDateTime) | $($token.lastSyncErrorCode) |`n" | ||
| Write-Output $($expiresInDays -gt $expirationThresholdDays -and $lastSyncDiffDays -eq 0) | ||
| } | ||
|
|
||
| $testResultMarkdown += '```' + "`n" | ||
| $testResultMarkdown += $automatedDeviceEnrollmentTokens | ConvertTo-Json | ||
| $testResultMarkdown += "`n" | ||
| $testResultMarkdown += '```' | ||
|
|
||
| Add-MtTestResultDetail -Result $testResultMarkdown | ||
| return $healthStatus -notcontains $false | ||
| } catch { | ||
| Add-MtTestResultDetail -SkippedBecause Error -SkippedError $_ | ||
| return $null | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm seeing the following error in my tenant.
InvalidArgument: /Users/merill/GitHub/maester/powershell/public/maester/intune/Test-MtAppleAutomatedDeviceEnrollmentToken.ps1:35
Line |
35 | $expiresInDays = [System.Math]::Ceiling(([datetime]$token …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot convert null to type "System.DateTime".I dug further and can see the rest api returning
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#deviceManagement/depOnboardingSettings",
"@odata.count": 0,
"@microsoft.graph.tips": "Use $select to choose only the properties your app needs, as this can lead to performance improvements. For example: GET deviceManagement/depOnboardingSettings?$select=appleIdentifier,dataSharingConsentGranted",
"value": []
}So in the code, it needs to read from .value
NOTE: I see the same issue with almost all the tests in this PR.
Can you confirm if these are working in your tenant?
I can see that in Test-MtIntuneRbacGroupsProtected you are reading the .value property correctly.
| $diagnosticSettingsRequest = Invoke-AzRestMethod -Method GET -Path "/providers/microsoft.intune/diagnosticSettings?api-version=2017-04-01-preview" | ||
| $diagnosticSettings = $diagnosticSettingsRequest | Select-Object -ExpandProperty Content | ConvertFrom-Json | Select-Object -ExpandProperty value | ||
|
|
||
| $testResultMarkdown = "Intune Diagnostic Settings:`n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .LINK | ||
| https://maester.dev/docs/commands/Test-MtAppleAutomatedDeviceEnrollmentToken | ||
| #> | ||
| function Test-MtAppleAutomatedDeviceEnrollmentToken { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return $null | ||
| } | ||
|
|
||
| try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .LINK | ||
| https://maester.dev/docs/commands/Test-MtFeatureUpdatePolicy | ||
| #> | ||
| function Test-MtFeatureUpdatePolicy { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Hi @merill, I changed the behaviour of the failing tests and re-tested them in my tenant after deleting some of the tokens. All tests referring to a token or connector are now only performed if they exist, otherwise test execution is skipped. Based on my opinion this approach reflects the 'as-is-state' better in the test report and is more comprehensive:
Example test results for an individual check:
|
|
Awesome. Looks good now @nicolonsky !! |






Description
Contribution Checklist
Before submitting this PR, please confirm you have completed the following:
/powershell/tests/pester.ps1on your local system.Join us at the Maester repository discussions 💬 or Entra Discord 🧑💻 for more help and conversations!