Tag Archives: SCOM. PowerShell

Automatically Closing Old SCOM Alerts using PowerShell

If you a SCOM administrator, then you are familiar with seeing old alerts piling up in your SCOM console. No matter how much you clean up your monitoring environment, some alerts will be left over unless you manually remove them, depending on how you have configured alert resolutions.

Following PowerShell script from Microsoft SCOM blog will allow you to automatically close old SCOM alerts.The logic behind this script is, that it will traverse the active alerts and checks for alert age. If the alert age is greater than the specified number of days in the $alertsTobeClosedBefore variable, those alerts will be closed.

Remember to load the SCOM PowerShell Module before you run this script.

$alertsTobeClosedBefore = 5

$currentDate = Get-Date

Get-SCOMAlert | Where-Object {(($_.ResolutionState -ne 255) -and (($currentDate – $_.TimeRaised).TotalDays -ge $alertsTobeClosedBefore))} |Resolve-SCOMAlert

 

Removing SCOM MPs like a Boss

It’s not like everyday you might want to remove certain management packs from your SCOM management group. The most  painful task is removing the dependent MPs as you need to manually track all of those and delete them first in order to successfully remove the parent management pack.

Microsoft Senior Software Engineer Chandra Bose has written a PowerShell script that can  identify and remove all of the dependent management packs automatically in such situations. Lets explore that script a little in this post.

How to get started?

First of all you need to run the Operations Manager Command shell as an administrator,  which should be a member of the Operations Manager Administrators group as well.

When you execute the script you can either provide the ID or the System Name of the parent management pack as below. You can find the MP ID by visiting Administration > Management Packs > Right click the desired MP and select properties > Look for the ID field in the General tab which shows the MP ID. The System Name is the unique name of the MP (i.e Microsoft.SQLServer.2012.Discovery)

 .\RecursiveRemove.ps1 <ID or System Name of the MP>

You can download the RecursiveRemove.ps1 script from here.