From a181d5dc9d5f2743e965dc0d167ff448ab5b49d2 Mon Sep 17 00:00:00 2001 From: Thomas De Reyck Date: Thu, 6 Aug 2026 10:12:06 +0200 Subject: [PATCH] Added a filter to the version reporting script. Only clients that have been online in the last 30 days will be shown. --- .../intune/report_managed_device_versions.ps1 | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/microsoft/intune/report_managed_device_versions.ps1 b/microsoft/intune/report_managed_device_versions.ps1 index 83b2ddc..d7f6460 100644 --- a/microsoft/intune/report_managed_device_versions.ps1 +++ b/microsoft/intune/report_managed_device_versions.ps1 @@ -1,3 +1,5 @@ +$Today = Get-Date + Connect-MgGraph -NoWelcome $Devices = Get-MgDeviceManagementManagedDevice -All @@ -15,6 +17,12 @@ $MacOsDevices = @{} $WindowsDevices = @{} ForEach($Device in $Devices) { + + If($Device.LastSyncDateTime.AddDays(30) -lt $Today) { + # Device has not checked in for a month. Not including it in report. + Continue + } + If($Device.OperatingSystem -like "Windows") { $WindowsTotal += 1 If($WindowsDevices[$Device.OSVersion]) { @@ -23,7 +31,7 @@ ForEach($Device in $Devices) { $WindowsDevices.Add($Device.OSVersion,1) } - If($Device.OSVersion -like "10.0.2*") { + If($Device.OSVersion -like "10.0.262*") { $WindowsLatestCount += 1 } Else { $WindowsOtherCount += 1 @@ -37,7 +45,7 @@ ForEach($Device in $Devices) { $MacOsDevices.Add($Device.OSVersion,1) } - If($Device.OSVersion -like "15.*") { + If($Device.OSVersion -like "26.*") { $MacOsLatestCount += 1 } Else { $MacOsOtherCount += 1 @@ -62,9 +70,9 @@ $MacOsResults = $MacOsDevices.GetEnumerator() | Sort-Object -Property Name -Desc " "

Managed Devices Version Report

" "

Windows Devices

" -"

There are $WindowsTotal managed Windows devices:" +"

There are $WindowsTotal managed Windows devices (that have checked in in the last month):" "

" "

" @@ -73,7 +81,7 @@ $MacOsResults = $MacOsDevices.GetEnumerator() | Sort-Object -Property Name -Desc "VersionNumber of devices" ForEach($Result in $WindowsResults) { - If($Result.Name -Like "10.0.2*") { + If($Result.Name -Like "10.0.262*") { "$($Result.Name)$($Result.Value)" } Else { "$($Result.Name)$($Result.Value)" @@ -83,9 +91,9 @@ ForEach($Result in $WindowsResults) { "" "

macOS Devices

" -"

There are $MacOsTotal managed macOS devices:" +"

There are $MacOsTotal managed macOS devices (that have checked in in the last month):" "

" "

" @@ -94,7 +102,7 @@ ForEach($Result in $WindowsResults) { "VersionNumber of devices" ForEach($Result in $MacOsResults) { - If($Result.Name -Like "15.*") { + If($Result.Name -Like "26.*") { "$($Result.Name)$($Result.Value)" } Else { "$($Result.Name)$($Result.Value)"