Reviewing SCOM 2012 Agent Patchlist using PowerShell

Recently needed to do that at a customer site and found this thread:

http://social.technet.microsoft.com/Forums/systemcenter/en-US/4fc39732-bcf9-4471-a597-aaebb342628d/powershell-cmdlet-to-obtain-patch-list-from-agents

However, it doesn’t work properly in SCOM 2012.

Challenge accepted!

Now, here’s the functional code for 2012 and up:

$agents=get-scomagent
$value=$agents[0].HostedHealthService.GetMonitoringProperties() | ? {$_.Name -eq “PatchList”}

$agents | ft -auto Name, @{Label=”PatchList”; Expression={$_.hostedhealthservice.getmonitoringpropertyvalue($value)}}

 

 

Hope it helps!