I’m trying to setup a SCOM Command Channel that runs a PowerShell script (to send a Slack message) every time an alert from specific servers fires.
I have the channel setup and the script works fine but it just doesn’t seem to be working. There’s no output in event viewer and I don’t receive any messages. I’ve tried adding
>> C:\DC\log\log.txt to the end of the parameters to try and get some output but nothing gets saved (I’ve given Everyone permission to write to that directory temporarily).
Does anyone know how else I should go about debugging the channel?
The command channel is configured as follows:
Full path of the command line
Command line parameters
-executionPolicy bypass -noprofile -file "C:\DC\slack-send.ps1" "$Data/Context/DataItem/AlertId$" "$Data/Context/DataItem/AlertName$" "$Data/Context/DataItem/ManagedEntityPath$" "$Data/Context/DataItem/ManagedEntityDisplayName$" "$Data/Context/DataItem/Severity$" >> C:\DC\log\log.txt
I blogged about posting via webhook to teams a while back (http://blog.beyondimpactllc.com/blog/post-scom-alerts-to-microsoft-teams). I kept the mechanism as simple as possible. Powershell in SCOM can be a bit finicky. Can you test without the -executionpolicy and the -noprofile to see if it runs using just the incoming parameters I assume you’ve defined in your script?
I am only on my phone so I cannot try your channel my self, but I have done the same thing to msft teams. See if you can get anything out of this http://adatum.no/operationsmanager/scom-alerts-to-microsoft-teams-and-mattermost
You should check out the Event Log for Microsoft-Windows-PowerShell/Operational as well, see if any errors or warnings are present.
Check that the Powershell file is unblocked depending on your version of Windows, go to the file right click on properties.
Try changing the Startup Folder to C:\DC remove the last \
When you say you know the script works, did you test it the way SCOM runs it? Open Command Prompt, CD to the startup folder, and run the full path command line, along with the Parameters? does that work properly or error?
Have you tried paring the script back to a hello-world script (that just writes to a file, for example) to test the basics are working? You could then also try removing the arguments from the notification channel until you’re down to the most basic powershell command. Hopefully that will help track down which piece is breaking. Also BTW I suspect you can’t do >> log.txt as SCOM will probably be using ShellExecute to execute this command (not cmd.exe).