107 lines
2.9 KiB
PowerShell
107 lines
2.9 KiB
PowerShell
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
|
|
|
|
"<html><head>
|
|
<style>
|
|
body { font-family: sans-serif; }
|
|
table, th, td { border: 1px solid black; border-collapse: collapse; }
|
|
table {font-family: monospace; }
|
|
th, td {padding-left: 5px; padding-right: 5px;}
|
|
.version { text-align: right; }
|
|
.good { color: green;}
|
|
.bad { color: red;}
|
|
</style>
|
|
</head><body>"
|
|
"<h1>Managed Devices Version Report</h1>"
|
|
"<h2>Windows Devices</h2>"
|
|
"<p>There are <strong>$WindowsTotal</strong> managed Windows devices:"
|
|
"<ul>"
|
|
"<li class='good'>$WindowsLatestCount devices are running Windows 11.</li>"
|
|
"<li class='bad'>$WindowsOtherCount devices are running another version of Windows.</li>"
|
|
"</ul>"
|
|
"</p>"
|
|
|
|
"<table>"
|
|
"<tr><th>Version</th><th>Number of devices</th></tr>"
|
|
|
|
ForEach($Result in $WindowsResults) {
|
|
If($Result.Name -Like "10.0.2*") {
|
|
"<tr class='good'><td>$($Result.Name)</td><td class='version'>$($Result.Value)</td></tr>"
|
|
} Else {
|
|
"<tr class='bad'><td>$($Result.Name)</td><td class='version'>$($Result.Value)</td></tr>"
|
|
}
|
|
}
|
|
|
|
"</table>"
|
|
|
|
"<h2>macOS Devices</h2>"
|
|
"<p>There are <strong>$MacOsTotal</strong> managed macOS devices:"
|
|
"<ul>"
|
|
"<li class='good'>$MacOsLatestCount devices are running macOS Sequoia.</li>"
|
|
"<li class='bad'>$MacOsOtherCount devices are running another version of macOS.</li>"
|
|
"</ul>"
|
|
"</p>"
|
|
|
|
"<table>"
|
|
"<tr><th>Version</th><th>Number of devices</th></tr>"
|
|
|
|
ForEach($Result in $MacOsResults) {
|
|
If($Result.Name -Like "15.*") {
|
|
"<tr class='good'><td>$($Result.Name)</td><td class='version'>$($Result.Value)</td></tr>"
|
|
} Else {
|
|
"<tr class='bad'><td>$($Result.Name)</td><td class='version'>$($Result.Value)</td></tr>"
|
|
}
|
|
}
|
|
|
|
"</table>"
|
|
|
|
"</body></html>"
|