Hi All,
We are trying to update the custom alert field with MP name
with the below modified script. On some of the alerts we are able to update but its not working smoothly on all the alerts as per the critieria set.
Import-Module OperationsManager
New-SCOMManagementGroupConnection
$alerts = Get-SCOMAlert | where {$_.ResolutionState -eq "0" -and $_.Severity -eq "2"}
foreach ($alert in $alerts)
{
$alert.CustomField1 = $alert.NetBiosComputerName
$alert.CustomField2 = $alert.Severity
$alert.ResolutionState = "5"
if ($alert.IsMonitorAlert -like 'False')
{
$alert.CustomField3 =
((get-SCOMrule $alert.monitoringruleid).getmanagementpack()).displayname
}
else
{
$alert.CustomField3 = (
get-SCOMmonitor $alert.monitoringruleid).getmanagementpack().displayname
}
$alert.Update("Filling the CustomFields")
}
exit
Any inputs to make it work for all the alerts
Any better solution available with anyone.
Thanks
Sunil
| 9:27 PM (1 hour ago) | ![]() ![]() | ||
|
Import-Module OperationsManager
New-SCOMManagementGroupConnection
$alerts = Get-SCOMAlert | where {$_.ResolutionState -eq "0" -and $_.Severity -eq "2"}
foreach ($alert in $alerts)
{
$alert.CustomField1 = $alert.NetBiosComputerName
$alert.CustomField2 = $alert.Severity
$alert.ResolutionState = "5"
if ($alert.IsMonitorAlert -like 'False')
{
$alert.CustomField3 =
((get-SCOMrule $alert.monitoringruleid).getmanagementpack()).displayname
}
else
{
$alert.CustomField3 = (
get-SCOMmonitor $alert.monitoringruleid).getmanagementpack().displayname
}
$alert.Update("Filling the CustomFields")
}
exit
| 9:27 PM (1 hour ago) | ![]() ![]() | ||
|
Import-Module OperationsManager
New-SCOMManagementGroupConnection
$alerts = Get-SCOMAlert | where {$_.ResolutionState -eq "0" -and $_.Severity -eq "2"}
foreach ($alert in $alerts)
{
$alert.CustomField1 = $alert.NetBiosComputerName
$alert.CustomField2 = $alert.Severity
$alert.ResolutionState = "5"
if ($alert.IsMonitorAlert -like 'False')
{
$alert.CustomField3 =
((get-SCOMrule $alert.monitoringruleid).getmanagementpack()).displayname
}
else
{
$alert.CustomField3 = (
get-SCOMmonitor $alert.monitoringruleid).getmanagementpack().displayname
}
$alert.Update("Filling the CustomFields")
}
exit