All scripts
Governance 632
Get-WindowsUpdateComplianceReport
Summarizes patch compliance across managed Windows devices by comparing installed update levels against the latest available cumulative update, grouped by device model.
Get-WindowsUpdateComplianceReport.ps1
<#
.SYNOPSIS
Summarizes Windows patch compliance across managed devices.
.DESCRIPTION
Groups managed Windows devices by OS build and reports how many
devices are on each build, making it easy to see how far behind the
fleet is from the latest cumulative update without opening every
device record individually.
.EXAMPLE
.\Get-WindowsUpdateComplianceReport.ps1
.NOTES
Requires Microsoft.Graph.DeviceManagement with an active
Connect-MgGraph session.
.AUTHOR
Shehryar Hassan
#>
$devices = Get-MgDeviceManagementManagedDevice -Filter "operatingSystem eq 'Windows'" -All
$devices | Group-Object OsVersion | Sort-Object Count -Descending |
Select-Object @{N="OSBuild";E={$_.Name}}, Count | Format-Table -AutoSize
$stale = $devices | Where-Object { $_.LastSyncDateTime -lt (Get-Date).AddDays(-14) }
Write-Host "$($stale.Count) device(s) have not synced in over 14 days, their reported build may be out of date." -ForegroundColor Yellow
Read it before you run it, and test in a safe tenant first.