Run a Powershell script Alarm action

I'm trying to run a powershell script for failed jobs alarm to push to a Webhook in MS Teams. The PS works when run from both my Spotlight server and the monitored server directly from Powershell Command window but not when the alarm is triggered? WinRM is running on the monitored server and the account used has access to the server also. Any tips?

Script:Invoke-RestMethod -Method post -ContentType 'Application/Json' -Body '{"text":"Hell World!"'-Uri [my Teams Channel]

Many thanks,

Steve