cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Level 12

Slack integration PowerShell script: loop through Alert Message and evaluate various contents

We're using the Slack integration and PowerShell script, like so many others are doing. It's really fantastic. One thing we want to do is iterate through the Alert Message (which is passed to the script), and do things. One element of our Alert Message is severity:

Severity: ${N=Alerting;M=Severity}

so I'd like to have an if loop that looks at Severity, and uses different emoji's, dependent on what the value of Severity is. Once the script is running and has that alert message, I'm assuming it is then some sort of PowerShell object, and we can access all the elements inside. Typically when figuring out what's available in a PS object that my scripts are ingesting, I run Visual Studio in debug mode, then I can see everything available in the left pane. For this SolarWinds alert, I'm having trouble just figuring out how I'll be accessing the value of Severity, which should be in Var1

param([string[]]$Var1)
 
Any suggestions from the more savvy PowerShell folks out there?
Tags (1)
0 Kudos
1 Reply
Highlighted
Level 12

Re: Slack integration PowerShell script: loop through Alert Message and evaluate various contents

Today a colleague gave me an idea to keep this simpler. Instead of looping through the Alert Message, we'll just pass an additional Param in the SolarWinds alert. So in addition to passing AlertMessage, we'll also pass Severity. Then it should be fairly simple to evaluate that Param, and do different emojis based on the value.

So instead of this: 

param([string[]]$Var1)

...we would do something like this?

param([string[]]$Var1, [string[]]$Var2)

Then I would have an If statement that evaluates Var2

I'm not proficient enough yet to know what to do with those Params, (and I'll play around with it over the weekend. But if anyone knows just what to do, please chime in. I appreciate the help!!

 

0 Kudos