Skip to main content
Microsoft Intune · PowerShell 7.6

Operating system versions across Intune devices

How many Intune-managed devices run each operating system version? Useful before an OS minimum-version compliance rule or an end-of-support date.

Script

#Requires -Modules Microsoft.Graph.Authentication, Microsoft.Graph.DeviceManagement
# Number of Intune managed devices per operating system and version. Read-only.
param(
    [string]$OperatingSystem
)

Connect-MgGraph -Scopes 'DeviceManagementManagedDevices.Read.All' -NoWelcome

Get-MgDeviceManagementManagedDevice -All -Property 'id', 'operatingSystem', 'osVersion' |
    Where-Object { -not $OperatingSystem -or $_.OperatingSystem -eq $OperatingSystem } |
    Group-Object -Property OperatingSystem, OsVersion |
    ForEach-Object {
        [pscustomobject]@{
            OperatingSystem = $_.Group[0].OperatingSystem
            OsVersion       = $_.Group[0].OsVersion
            Devices         = $_.Count
        }
    } |
    Sort-Object OperatingSystem, @{ Expression = 'Devices'; Descending = $true }

Checked automatically against Microsoft's published cmdlet reference. KBY hasn't run it in your tenant; run it in a test environment first.

Reading the output

  • Counts devices by the operatingSystem and osVersion values each device reports to Intune. Windows versions are build numbers (for example 10.0.26100.xxxx); the Windows release information page maps builds to versions.
  • Pass -OperatingSystem Windows (or iOS, Android, macOS) to count one platform only.

Sources

The Microsoft reference page for every cmdlet the script calls, plus the API and product pages behind each permission and caveat.

All scripts