# Powershell: Getting alerts with group as criteria

**URL:** <https://community.squaredup.com/t/powershell-getting-alerts-with-group-as-criteria/524>\
**Category:** PowerShell\
**Tags:** script, scom, powershell\
**Created:** [November 7, 2017, 12:03pm UTC](https://community.squaredup.com/t/powershell-getting-alerts-with-group-as-criteria/524 "2017-11-07T12:03:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bottekott](https://community.squaredup.com/letter_avatar_proxy/v4/letter/b/8797f3/32.png) [@bottekott](https://community.squaredup.com/u/bottekott)\
**Post date:** [November 7, 2017, 12:03pm UTC](https://community.squaredup.com/t/powershell-getting-alerts-with-group-as-criteria/524/1 "2017-11-07T12:03:22Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Jelly](https://community.squaredup.com/user_avatar/community.squaredup.com/jelly/32/812_2.png) [@Jelly](https://community.squaredup.com/u/Jelly)\
**Post date:** [November 7, 2017, 12:14pm UTC](https://community.squaredup.com/t/powershell-getting-alerts-with-group-as-criteria/524/2 "2017-11-07T12:14:08Z")

</div>

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](https://blog.tyang.org/2010/06/25/morning-check-scom-alerts-%e2%80%93-automated-using-powershell-script/)

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

---

<div class="post-metadata">

**Author:** ![bottekott](https://community.squaredup.com/letter_avatar_proxy/v4/letter/b/8797f3/32.png) [@bottekott](https://community.squaredup.com/u/bottekott)\
**Post date:** [November 8, 2017, 11:01am UTC](https://community.squaredup.com/t/powershell-getting-alerts-with-group-as-criteria/524/3 "2017-11-08T11:01:46Z")

</div>

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.

&nbsp;

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/](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!

---

<div class="post-metadata">

**Author:** ![darrenj](https://community.squaredup.com/letter_avatar_proxy/v4/letter/d/94ad74/32.png) [@darrenj](https://community.squaredup.com/u/darrenj)\
**Post date:** [November 9, 2017, 10:27am UTC](https://community.squaredup.com/t/powershell-getting-alerts-with-group-as-criteria/524/4 "2017-11-09T10:27:13Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![grahamp](https://community.squaredup.com/letter_avatar_proxy/v4/letter/g/9de053/32.png) [@grahamp](https://community.squaredup.com/u/grahamp)\
**Post date:** [August 22, 2024, 3:45am UTC](https://community.squaredup.com/t/powershell-getting-alerts-with-group-as-criteria/524/5 "2024-08-22T03:45:27Z")

</div>

Hi Darren, would you mind at all sharing your script with me? Sounds great, seems like what I could use instead of reinventing the wheel 🙂
