Hi Robert Christensen,
Thanks for giving your problem to us.
The exit code 1 indicates a generic failure. The Write-Error cmdlet was explicitly called by the script author to halt execution because the UI element or API state required for the "Send" operation was inactive. Since the script is located in AppData\Local\Temp, it is likely a transient script generated by a third-party application or a monitoring agent.
To resolve this issue, try to follow these troubleshooting steps:
- Validate Input Data
Ensure that the data being passed to the script is complete. A "Send" button remains disabled in most gateway interfaces if:
- The Destination Number is missing or improperly formatted (e.g., missing country code).
- The Message Body exceeds character limits or is empty.
- The API Credentials or Session Token has expired.
- Address Timing and Race Conditions
If this script utilizes UI Automation (e.g., Selenium or WinAppDriver), the script may be attempting to click the button before the application has fully initialized.
Solution: Implement a "Wait" logic to ensure the element is Enabled before the interaction occurs.
- Inspect the Originating Application
Since the script is generated in the Temp folder, the root cause usually lies in the configuration of the parent software.
Check the logs of the service that triggered smsgateway_send_*.ps1.
Ensure the service account running the script has the appropriate permissions to interact with the network or the gateway UI.
For further technical deep-dives into handling these types of PowerShell exceptions, you can refer to some of the following Microsoft resources:
Handling Script Errors: About Throw | Microsoft Learn
PowerShell Error Action Preference: About CommonParameters | Microsoft Learn
Windows UI Automation Overview: UI Automation Support for Standard Controls
If you find the answer useful, please mark it as the "Accepted Answer" so other members can find the solution easily. Your help in supporting the community is much appreciated!
Best regards,
Scott Nguyen