Hi, @norbq98
Thank you for posting in Microsoft Q&A forum.
To execute a script when an alert becomes active in SCCM, you can create a Status Filter Rule that triggers the script when the alert is raised. The Status Filter Rule should be created on the component "SMS_ALERT_NOTIFICATION". You can verify that the rule is working by checking the SMS_StatusMessage WMI class.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Add comment".