Skip to content

Get-MgmtGraphDeviceCompliancePolicyDeviceStatusOverview

MgmtGraph: Audits status overview for an Intune compliance policy

#Requires -Version 5.1
#Requires -Modules Microsoft.Graph.DeviceManagement

[CmdletBinding()]
Param (
    [Parameter(Mandatory = $true, Position = 0)]
    [string]$Identity
)

Process {
    try {
        $overview = Get-MgDeviceManagementDeviceCompliancePolicyDeviceStatusOverview -DeviceCompliancePolicyId $Identity -ErrorAction Stop
        
        $result = [PSCustomObject]@{
            PolicyId             = $Identity
            SuccessCount         = $overview.SuccessCount
            NotApplicableCount   = $overview.NotApplicableCount
            PendingCount         = $overview.PendingCount
            ErrorCount           = $overview.ErrorCount
            FailedCount          = $overview.FailedCount
            ConflictCount        = $overview.ConflictCount
            Timestamp            = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
        }

        Write-Output $result
    }
    catch {
        throw
    }
}

Specifies the ID of the device compliance policy.

An interactive directory of PowerShell scripts.