PowerShell cmdlet to obtain Patch List from Agents
Good afternoon,
Is there a PowerShell cmdlet that returns the “Patch List” associated with a particular agent?
I’ve examined the get-agent cmdlet, but it does not report this information. Would I be better off passing a SQL command to the back-end database instead?
Larry
January 12th, 2011 3:24pm
Hi. I'm not sure if you're stuck on using the command shell, but there is a report in the System Center Central Health Check Reports MP.
http://www.systemcentercentral.com/PackCatalog/PackCatalogDetails/tabid/145/IndexId/69990/Default.aspxLayne
Free Windows Admin Tool Kit Click here and download it now
January 12th, 2011 5:38pm
Hi,
Took a bit of doing, but here you go:
$class = get-monitoringclass -name "Microsoft.SystemCenter.HealthService"
$property = $class.getmonitoringproperties() | ? { $_.Name -eq "PatchList" }
get-agent | ft -auto Name, @{Label="PatchList"; Expression={$_.hostedhealthservice.getmonitoringpropertyvalue($property)} }
Add a | out-file ... to get the output to a text file.
MattMatt White
( http://systemcenterblog.hardac.co.uk/ )
January 12th, 2011 6:48pm
Hi,
Took a bit of doing, but here you go:
$class = get-monitoringclass -name "Microsoft.SystemCenter.HealthService"
$property = $class.getmonitoringproperties() | ? { $_.Name -eq "PatchList" }
get-agent | ft -auto Name, @{Label="PatchList"; Expression={$_.hostedhealthservice.getmonitoringpropertyvalue($property)} }
Add a | out-file ... to get the output to a text file.
You can also change the last line to use format-list instead of format-table:
get-agent | fl Name, @{Label="PatchList"; Expression={$_.hostedhealthservice.getmonitoringpropertyvalue($property)} }
Matt
Matt White
( http://systemcenterblog.hardac.co.uk/ )
Free Windows Admin Tool Kit Click here and download it now
January 12th, 2011 6:50pm
Good morning Matt,
WOW!
That is exactly what I was looking for!
Having looked at your script, it becomes immediately evident that if I am to take my OpsMgr management skills to the next level, I will need to learn OpsMgr's "object
model" (i.e. class hierarchy, and properties & methods of each).
Where does one get this sort of information? Ideally, a chart with the class hierarchy along with support documentation with each class' properties & methods would prove quite useful!
Thanks again,
Larry
January 13th, 2011 10:40am
Hi,
Each management pack guide should have a class hierarchy. Also, the
Operations Manager SDK is excellent and a good place to research the object model.
I learned loads by wrinting my own SCOM
web service in visual studio. The built-in autocomplete is really handy.
Good luck!
MattMatt White
( http://systemcenterblog.hardac.co.uk/ )
Free Windows Admin Tool Kit Click here and download it now
January 16th, 2011 2:11pm