I have a looping script which runs automatically at start on a server.
To ensure that this script is always running, the first action of the loop is to call a PowerShell script which starts with a 30 min sleep, then if that expires, a shutdown -r command is run next. If the PA loop completes before 30 minutes, the PowerShell window is closed at the end of the loop, before being started again at the start of the next loop (starting another 30 minute timer).
Recently the loop is sporadically failing due to unknown reasons, as the server is unattended. The script is more than likely waiting for on-screen text via OCR when the time out/restart occurs (so the script hasn't technically "stopped" in PA terms). Whenever the restart command is run however, PA is not logging the script as a completed/failed/interrupted run, and no logs are being uploaded to make.powerautomate.com to assist me troubleshooting.
How can I ensure these logs are uploaded? Do I need to introduce an extra PowerShell command to "gracefully" terminate the hung PA script before the shutdown -r command?