PoshCode Archive  Artifact [6367141b62]

Artifact 6367141b6218d014dfe8bb0528ccf753e8c0c80853374c2b0187ec2e482b578e:

  • File Tag-Alert-SCOM.ps1 — part of check-in [552a1b7967] at 2018-06-10 14:02:03 on branch trunk — Tags alert with PrincipalName, Severity and MP name in Custom fields. (user: unknown size: 1261)

# encoding: ascii
# api: powershell
# title: Tag-Alert (SCOM)
# description: Tags alert with PrincipalName, Severity and MP name in Custom fields.
# version: 0.1
# type: script
# license: CC0
# x-poshcode-id: 582
# x-archived: 2008-09-19T16:44:26
#
# Use in OpsMgr Command Shell.
# Original script from Marco Shaw.
# Changed by Stefan Stranger
# Date created 13-09-2008
#
# Tags alert with PrincipalName, Severity and MP name in Custom fields.
# Use in OpsMgr Command Shell.
# Original script from Marco Shaw.
# Changed by Stefan Stranger
# Date created 13-09-2008
$alerts = get-alert | where {$_.principalname -ne $null -and $_.resolutionstate -eq "0"}
foreach($alert in $alerts)
      { 
            $alert.CustomField1 = $alert.PrincipalName 
            $alert.CustomField2 = $alert.Severity 
            if ($alert.IsMonitorAlert -like 'False') 
                  { 
                        $alert.CustomField3 = ((get-rule $alert.monitoringruleid).getmanagementpack()).displayname 
                  } 
            else 
                  { 
                        $alert.CustomField3 = ((get-monitor $alert.problemid).getmanagementpack()).displayname 
                  } 
                  $alert.Update("") 
      }