When it comes to notifications, we have many options – except one that people have asked about, a nag mode. Something that will re-send an email after a certain amount of time to make sure it’s taken care of.

Well, it does exist in OpsMgr.

Either intentionally or unintentionally as a bug, if you call the Update method on an alert without changing any criteria, the notification bound to the alert will re-fire. This will happen whether you add a comment with the update (Update(“Updating the alert”)) or not (Update(“”)).

To enable this secret nag-mode, it’s as simple as writing a Powershell script that runs every X hours. In that script you’ll just need to do a Get-Alert with the criteria you’re looking for – in the example I’m just going to have it return all alerts older then 4 hours, and update them.

It’s very simple though – how simple? Like this:

1
2
3
4
$oldAlerts = Get-Alert | Where-Object {($_.LastModified -ge [DateTime]::Now.AddHours(-4)) -and ($_.ResolutionState -eq 0)}
ForEach($alert in $oldAlerts) {
$alert.Update("")
}

You can expand this as much as you’d like. Match against NetBiosComputerName to only nag for those critical core servers, match it against the monitoring object to ensure critical monitors are being addressed. Multiple management groups? Match against that. You see where I’m going with this. In fact, you can find out everything you can match against by just running Get-Alert | select -first 1 – there’s all the fields available.

  2 Responses to “SCOM Snippet: The hidden nag mode”

  1. It has one problem the last modified time changes when we run alert.update.

  2. I have tried to run this script and it doesnt seem to work. Are you able to advise the correct way to run it? I am new to scom and not good with powershell. I get this:

    Get-Alert : The ‘Path’ parameter is empty or the required provider location is not
    set.”
    At C:\Documents and Settings\administrator\Desktop\testt.ps1:1 char:23
    + $oldAlerts = Get-Alert <<<< | Where-Object {($_.LastModified -ge [DateTime]::Now
    .AddHours(-1)) -and ($_.ResolutionState -eq 0)}
    + CategoryInfo : InvalidArgument: (:String) [Get-Alert], ArgumentOutO
    fRangeException
    + FullyQualifiedErrorId : InvalidParameter,Microsoft.EnterpriseManagement.Oper
    ationsManager.ClientShell.GetAlertCmdlet
    You cannot call a method on a null-valued expression.
    At C:\Documents and Settings\administrator\Desktop\testt.ps1:3 char:14
    + $alert.Update <<<< ("")
    + CategoryInfo : InvalidOperation: (Update:String) [], RuntimeExcepti
    on
    + FullyQualifiedErrorId : InvokeMethodOnNull

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

   
© 2012 Pavleck.NET Suffusion theme by Sayontan Sinha