15 mars 2011

Get all alerts from a management pack

For example, In SCOM if you want to retreive all alerts from a management packs, you can do something like this
$crit=""
$count=0
get-managementpack | ? { $_.Name -match "Citrix"} | % { $_.getclasses() | % {

    If ($count -eq 0) {$crit= "MonitoringClassId = '"+$_.id.tostring()+"'"; $count++}
    else { $crit= $crit + "OR MonitoringClassId = '"+$_.id.tostring()+"'" }
 }}
get-alert -criteria $crit

This powershell script retreive Citrix alerts...

Aucun commentaire: