I'm trying to use the Alert Manager to trigger an external application, well really a PowerShell script, but because PowerShell isn't an option in the trigger actions, I've selected external application and fed in PowerShell and the script name. I'm then trying to pass arguments to the PowerShell script which the script uses to do some action (Triggers a RESTful API call to some vendor service).
This isn't working, in fact, it doesn't appear to execute it at all, so I went dumb. I made a very basic script that takes 2 arguments, and writes to a log file...
param( [Parameter(Mandatory=$true)] [string]$Node, [Parameter(Mandatory=$true)] [string]$Status ) Add-Content -Path c:\temp\log.txt -Value $('{0} is in {1}' -f $Node, $Status)
Then I setup a test alert that has an alert trigger that looks like this:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe D:\Scripts\svc_check.ps1 -Node ${NodeName} -Status ${Node.Status}
I verified that local service had write access to the temp folder, and the file mentioned, I even used psexec to launch a command prompt as the local service account, and tested execution. When I trigger a test of the alert, it writes that the action was successful, and yet nothing was written to the temp file.
If I copy the line executed from the test log, and paste it into the same command prompt running in the service context, it works fine.
What am I missing? How can I enable more logging for the alert manager to see what's going on, because success isn't really true? Or am I just using the function incorrectly? Can we not pass arguments to executables?