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
" "There are $WindowsTotal managed Windows devices:" +"
There are $WindowsTotal managed Windows devices (that have checked in in the last month):" "
There are $MacOsTotal managed macOS devices:" +"
There are $MacOsTotal managed macOS devices (that have checked in in the last month):" "