Thursday, January 31, 2013

[OpsMgr 2012][Powershell] Get Alerts for all specified SCOM MP using powershell in Operations Manager 2012


Here is a short powershell script I've just updated to be usable in operations Manager 2012 since cmdlet have been renamed. This script will help you to retrieve alerts from a specified SCOM MP using powershell.
 

Note that previous version dedicated to Operations Manager 2007 R2 is here
  
Here is the new script :

  1. $mp = Get-SCOMManagementPack -name 'MPName'
  2. # Criteria       : All alerts, raw and processed descriptions.
  3. # Output to      : File (c:\temp\output\Alerts-all.csv)
  4. # Fields Selected: Lots.
  5. # Output Format  : CSV
  6. # Notes          : Need more work on this.
  7. $alerts_csv = "C:\MPName.csv";
  8. write-host "Exporting all alerts to csv: ",$alerts_csv;
  9. Get-SCOMAlert | select-object @{Name = '%'; expression ={$_.MonitoringObjectDisplayName}},Severity, Name, ResolutionState, RepeatCount,@{Name = 'Instances'; expression ={$_.RepeatCount+1}},@{Name = 'Created'; expression =
  10. {$_.TimeRaised.ToLocalTime()}},@{Name = 'Description (Processed)';Expression = {$_.Description  -replace "`n"," " -replace " "," "}},MonitoringObjectFullName, IsMonitorAlert,Id,MonitoringRuleId,MonitoringClassId,Description | sort Name | export-csv $alerts_csv -noTypeInformation;
 Replace MPName in red by the your MP Name. Il will export all alerts in a CSV file.

This posting is provided "AS IS" with no warranties.

No comments:

Post a Comment