Jaa


PowerShell Script: Extract Operations Manager Severity & Priority Information

 

MPViewer v1.7 returns no rule severity/priority data for the System Center Configuration Manager Management Pack version 6.0.6000.3 (27/9/2011).
This script can be used to extract that information.

    1: #requires -version 2
    2: <#
    3: author:              Johan Vosloo
    4: date:                3/11/2011
    5: info:                Must be executed from within the Operations Manager shell
    6: severity/alertlevel: https://msdn.microsoft.com/en-us/library/ms813440.aspx
    7: #>
    8: $error.clear()
    9: trap [System.Management.Automation.CommandNotFoundException] {"Command entered does not exist. Please ensure that you are running this script from within the System Center Operations Manager Shell.";continue} trap {"Errors were found.";continue}
   10: if ($error){return} else
   11: {
   12:     #MP
   13:     $configmp=get-managementpack -Name Microsoft.SystemCenter.ConfigurationManager.2007
   14:     #Rules
   15:     $ruleinfo=@()
   16:     $configmp_rules=$configmp.getrules()
   17:     $configmp_enabledrules=$configmp_rules | ?{$_.enabled -eq "true"}
   18:     foreach($configmp_enabledrule in $configmp_enabledrules)
   19:         {
   20:             foreach ($WriteAction in $configmp_enabledrule.WriteActionCollection)
   21:                 {
   22:                 $config=$writeaction.configuration
   23:                 if ($config.contains("<GenerateAlert>true")){
   24:                 $config -match "</Description><AlertLevel>(?<content>.*)</AlertLevel><ResolutionState/><Source>" | out-null
   25:                 switch ($matches['content'])
   26:                 {
   27:                     {$_ -le 20} {$alertlevel="Information";break}
   28:                     {$_ -le 40} {$alertlevel="Warning";break}
   29:                     {$_ -le 70} {$alertlevel="Critical";break}
   30:                 }
   31:                 }    
   32:                 }
   33:             $ruletmpobj=New-Object -Typename psobject –property @{displayname=$configmp_enabledrule.displayname;priority=$configmp_enabledrule.priority;severity=$alertlevel}
   34:             $ruleinfo+=$ruletmpobj
   35:         }
   36:            $ruleinfo | export-csv $home\Desktop\info.csv -notypeinformation
   37:            write-host "Rule data was extracted to $home\Desktop\info.csv" -ForegroundColor green
   38: }

Requirements:

  • System Center Operations Manager 2007 R2 (tested with CU4)
  • System Center Operations Manager 2007 R2 command shell
  • System Center Operations Manager 2007 R2 Administrator Privileges