Connect-MgGraph -Scopes "WindowsUpdates.ReadWrite.All" -NoWelcome $response = Invoke-MgGraphRequest -Method GET -Uri "https://graph.microsoft.com/beta/admin/windows/updates/products" $products = $response.value $issuesin72htotal = 0 $products | ForEach-Object { $targetid = $_.id $targetname = $_.name $response = Invoke-MgGraphRequest -Method GET -Uri "https://graph.microsoft.com/beta/admin/windows/updates/products/$targetid/knownIssues" $issues = $response.value $issuesin72h = 0 if ($issues.Count -gt 0) { $issues | ForEach-Object { if ($_.lastUpdatedDateTime -ge (Get-Date).AddHours(-72)) { $issuesin72h++ $issuesin72htotal++ } } } if ($issuesin72h -gt 0) { Write-Host "`n------------------------------------------------------------" Write-Host "$targetname known issues and notifications" Write-Host "------------------------------------------------------------`n" $issues | ForEach-Object { if ($_.lastUpdatedDateTime -ge (Get-Date).AddHours(-72)) { Write-Host "Title : $($_.title)" Write-Host "Status : " -NoNewLine if ($_.status -match 'resolved') { Write-Host $_.status -ForegroundColor Green } elseif ($_.status -match 'confirmed') { Write-Host $_.status -ForegroundColor Red } elseif ($_.status -match 'mitigated') { Write-Host $_.status -ForegroundColor Yellow } else { Write-Host $_.status -ForegroundColor Gray } Write-Host "Description : $($_.description)" Write-Host "URL : $($_.webViewUrl)" Write-Host "Updated : " -NoNewLine Write-Host $_.lastUpdatedDateTime -ForegroundColor Cyan Write-Host "" } } } } if ($issuesin72htotal -gt 0) { Write-Host $issuesin72htotal "updated information ware found." } else { Write-Host "No information has been updated in the past 72 hours." } DisConnect-MGGraph