Connect-MgGraph -NoWelcome $Devices = Get-MgDeviceManagementManagedDevice -All $MacOsTotal = 0 $WindowsTotal = 0 $WindowsLatestCount = 0 $WindowsOtherCount = 0 $MacOsLatestCount = 0 $MacOsOtherCount = 0 $MacOsDevices = @{} $WindowsDevices = @{} ForEach($Device in $Devices) { If($Device.OperatingSystem -like "Windows") { $WindowsTotal += 1 If($WindowsDevices[$Device.OSVersion]) { $WindowsDevices[$Device.OSVersion] += 1 } Else { $WindowsDevices.Add($Device.OSVersion,1) } If($Device.OSVersion -like "10.0.2*") { $WindowsLatestCount += 1 } Else { $WindowsOtherCount += 1 } } ElseIf($Device.OperatingSystem -like "macOS") { $MacOsTotal += 1 If($MacOsDevices[$Device.OSVersion]) { $MacOsDevices[$Device.OSVersion] += 1 } Else { $MacOsDevices.Add($Device.OSVersion,1) } If($Device.OSVersion -like "15.*") { $MacOsLatestCount += 1 } Else { $MacOsOtherCount += 1 } } } $WindowsResults = $WindowsDevices.GetEnumerator() | Sort-Object -Property Name -Descending $MacOsResults = $MacOsDevices.GetEnumerator() | Sort-Object -Property Name -Descending " " "

Managed Devices Version Report

" "

Windows Devices

" "

There are $WindowsTotal managed Windows devices:" "

" "

" "" "" ForEach($Result in $WindowsResults) { If($Result.Name -Like "10.0.2*") { "" } Else { "" } } "
VersionNumber of devices
$($Result.Name)$($Result.Value)
$($Result.Name)$($Result.Value)
" "

macOS Devices

" "

There are $MacOsTotal managed macOS devices:" "

" "

" "" "" ForEach($Result in $MacOsResults) { If($Result.Name -Like "15.*") { "" } Else { "" } } "
VersionNumber of devices
$($Result.Name)$($Result.Value)
$($Result.Name)$($Result.Value)
" ""