<# .SYNOPSIS Audits Intune-managed devices for compliance with security baselines. .DESCRIPTION This script retrieves a list of devices managed by Intune and checks their compliance status by fetching the associated mobile app policy for each device. Ideal for regular compliance checks. .NOTES Author: Souhaiel Morhag Company: MSEndpoint.com Blog: https://msendpoint.com Academy: https://app.msendpoint.com/academy LinkedIn: https://linkedin.com/in/souhaiel-morhag GitHub: https://github.com/Msendpoint License: MIT .EXAMPLE .\Audit-IntuneCompliance.ps1 #> [CmdletBinding()] param () try { # Retrieve all Intune managed devices $devices = Get-IntuneManagedDevice # Check compliance for each device foreach ($device in $devices) { # Fetch mobile app policy for the current device $compliancePolicy = Get-IntuneMobileAppPolicy -DeviceId $device.Id Write-Output "Device ID: $($device.Id), Compliance Status: $($compliancePolicy.Status)" } } catch { Write-Error "An error occurred: $_" }