Powershell: Getting alerts with group as criteria

I’m trying to create a powershell script that sends a daily report to our techs with active alerts.

We already have groups populated with servers and other objects each tech is responsible for.

I only know basic powershell, but I’ve been looking at other script and I’m now sending a daily report to myself, containing all open alerts, and alerts closed the last 24 hours.

But I can’t figure out how to get the Get-SCOMGroup and Get-SCOMAlert cmdlets to work together so that I can list only alerts with a relationship to a certain group.

I was hoping it was as easy as doing Get-SCOMGroup tech1| Get-SCOMClassInstance | Get-SCOMAlert. But this does not catch all alerts.

Anyone done this, or know how I should go about doing it?

1 Like

Tao Yang did a write up similar to this a little while ago and has his script available:

Morning Check SCOM Alerts – Automated using PowerShell Script

Hopefully, you’ll be able to grab what you need from there!

1 Like

Thanks Jelly. Taos script seemed a bit complicated for me, and was pretty old, so had to rewrite some of the cmdlets.

I did not get it to work the way I wanted to, I could not get it to match all the objects in the groups to the alerts.

 

I found another solution over at Stefan Roths blog:

https://stefanroth.net/2013/12/03/scom-2012-get-alerts-from-scom-group-showing-alert-source-information-management-pack-object-path-monitor-rule-name-etc/

And ended up doing:

$Group = Get-SCOMGroup -DisplayName $GroupName
$classinstance = $Group.GetRelatedMonitoringObjects('Recursive')
Get-SCOMAlert -Instance $classinstance

This did the trick for me!

1 Like

I have a script I use to do this and it runs every day and generates an HTML email to send to engineers for alerts 48hours open. If you get stuck let me know.

(added – I have emailed you some scripts that may help).

1 Like