OpsMgr 2012: Reset Unit Monitors in Bulk with PowerShell

What if you need to hit the ‘reset’ button for a large number of unit monitor instances in your System Center 2012 Operations Manager deployment for a specific unit monitor? This is definitely something that comes up on a recurring basis, and as ARentsch points out in this forum thread, not too difficult in Operations Manager 2012.

To reset monitors efficiently in bulk, you’ll only want to reset monitors for which the target is in an unhealthy state. So your logic would be:

  • Retrieve the monitor for which you’d like to reset (by Display Name is easiest)
  • Retrieve the class targeted by the unit monitor
  • Retrieve the instances of the target class that are unhealthy and reset

Here is a quick sample to demonstrate how to do this in the Operations Manager Command Shell.

Sample Script

This sample script will reset instances of the ‘Health Service Heartbeat Failure’, which targets the ‘Health Service Watcher’ class. This information is all readily accessible in the monitor properties, accessible from multiple locations in the Operations console.

Want to run this from a standard PowerShell window? Add this snippet to the beginning of the snippet above. Be sure to change the name of the OpsMgr management server in first line!

Full snippet for use in a standard PowerShell instance (for scheduled tasks, etc) would look like this:

Additional Resources

You’ll find a growing number of System Center, Cloud and PowerShell resources here on SCC in the “Master Collection of System Center PowerShell” and elsewhere. A few related Operations Manager 2012 Command Shell articles

OpsMgr 2012: Find Computers without the Active Directory Helper Object (OOMADS) with PowerShell

OpsMgr 2012: Disabling Rules and Monitors in Bulk in PowerShell

OpsMgr 2012: Group Maintenance Mode via PowerShell (the way it should be)

OpsMgr 2012: Running a Task in Bulk Using PowerShell

OpsMgr 2012: Automating Agent Discovery and Deployment with PowerShell [sample script]

OpsMgr 2012: Identifying Computers in Active Directory without an OpsMgr Agent Installed [sample script]

OpsMgr 2012 Quick Tip: Finding servers experiencing the most heartbeat failures with PowerShell

2 thoughts on “OpsMgr 2012: Reset Unit Monitors in Bulk with PowerShell

  1. curtmcgirt

    it’s interesting that “targeted class display name” is not exposed more easily in the properties of a monitor. we can get to the name of the class, more or less, but not the display name

    $_.Target.identifier.path

    unfortunatley that has {these} around it, so it would be hard to use in a script.

    $_.Target has a “name” field but is empty.

    “$_.target | select identifier” has the target name in it without {these} but i’m not sure how to extract it.

    PS C:\Users\john.curtiss> $target.target |select identifier

    Identifier
    ———- 1|Microsoft.Windows.Server.2003/31bf3856ad364e35|1.0.0.0|Microsoft.Windows.Server.2003.LogicalDisk||

  2. curtmcgirt

    oh nevermind on {these}.

    $_.Target.identifier.path works for the .name property of the class.

    so $monitoringclass =$monitor.target.identifier.path would also work in your script,

     

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.