As per my understanding, you need to execute a script whenever threshold is met adn alert is fired right?
We have a trigger action named "Execute a Script" and i tried using power shell script which functions perfectly fine for me.
But i do call API and try to forward the respective alert/event to third party tool.
If you want to execute the script on the same server for which alert has triggered, i may suggest you to check the script for "Top 10 processes for CPU" out-of-box alert where you find the script to check the processes on corresponding server.
Note: I suppose you may know it still i am mentioning that you need to have proper access/permissions to execute the script on server.
Hope this helps