SCOM script execution timeout

Using Community.PowerShellMonitoring version, I created a diagnostic task for the health service watcher heartbeat failure. Every time the heartbeat state changes to critical, a script will determine the gateway IP address of the computer and try to ping its connectivity, storing the value in a custom attribute of the computer class.

In the test environment, it was working fine, but in production with numerous objects, it exceeded its runtime execution.

What is the maximum runtime of the script executed on the management server?

I think the default is 300 seconds. You could set up your script to time out the tnc earlier, but what are you doing with this info exactly ?