Intermittent job failures with one of my scheduled scripts? Others similar to it haven't failed yet

Product: PowerShell Universal
Version: 2.12.4

Hi everyone,

Trying to figure this one out at the moment. I have about 7 scheduled jobs that run weekly. One of them runs every morning at 12:00am and the other 6 run every Monday, Wednesday, and Friday between 12:05-12:30am.

The scripts simply check various AD Org Units for users with password and account expirations coming up. It collects the data into a hashtable and emails that report to our team and managers of the users affected. Well one of the scripts is just a little bit different. It monitors password expirations like the others, but it sends an individual email to each user that has an upcoming password expiration. Usually this is about 10-15 people. It then sends another mail message to our team with a CSV report of the users affected (like the others).

The problem I am running into is that every 7 days or so… give or take a day, I wake up to see a job failure message in our Slack room from PSU. I log onto the server and take a look at the failed job, its always the one I just described that emails all the users separately and our team and the error is:

Oct 4, 2022 12:06 AM  Error Type: 
Oct 4, 2022 12:06 AM  System.Management.Automation.ErrorRecord 
Oct 4, 2022 12:06 AM  
 
Oct 4, 2022 12:06 AM  Error Position: 
Oct 4, 2022 12:06 AM  At C:\ProgramData\UniversalAutomation\Repository\scripts\schedules\Expire-Passwords.ps1:117 char:13 
Oct 4, 2022 12:06 AM  
 
Oct 4, 2022 12:06 AM  Error Line: 
Oct 4, 2022 12:06 AM  Send-MailMessage -To $userTo -From $From -Bcc $userBcc -Subject $userSubject -Body $userBody -SmtpServer $SmtpServer -BodyAsHtml -Priority High -WarningAction Ignore 
Oct 4, 2022 12:06 AM  
 
Oct 4, 2022 12:06 AM  Error Message: 
Oct 4, 2022 12:06 AM  The operation has timed out. 
Oct 4, 2022 12:06 AM

If I simply log in to the PSU web client and re-run the script, it completes just fine! I am running all the jobs in the Integrated environment. I did just try changing the environment to Windows PowerShell 5.1 to see if that changes anything? I also updated the appsetttings.json to change the following:

"UniversalAutomation": {
    "JobHandshakeTimeout": 30,
    "JobDebugging": false,
    "ContinueJobOnServerStop": false
}

At the end of the day, I’m not sure if this is just random goofiness from using Send-MailMessage? Although for multiple years I had this script running in a Jenkins master server and never had this issue.