GRPC error when scheduled script is ran

Product: PowerShell Universal
Version: 5.07

I have a script that runs fine when manually ran from Universal. when I schedule it to run everyday it fails in the middle of the script with a gRPC error:
I can consistently get this error but only if the schedule runs the script, not when ran manually. It happens in all powershell environments.

2024-09-24 06:03:36.396 -07:00 [INF] Error executing job 69: Status(StatusCode=“Unavailable”, Detail=“failed to connect to all addresses”, DebugException=“Grpc.Core.Internal.CoreErrorDetailException: {“created”:”@1727183016.395000000",“description”:“Failed to pick subchannel”,“file”:“…....\src\core\ext\filters\client_channel\client_channel.cc”,“file_line”:3218,“referenced_errors”:[{“created”:“@1727183016.395000000”,“description”:“failed to connect to all addresses”,“file”:“…....\src\core\lib\transport\error_utils.cc”,“file_line”:165,“grpc_status”:14}]}") at ProtoBuf.Grpc.Internal.Reshape.UnaryTaskAsyncImpl[TRequest,TResponse](AsyncUnaryCall1 call, MetadataContext metadata, CancellationToken cancellationToken) at UniversalAutomation.Services.GrpcExecutionService.ExecuteScript(Job job, ExecutionEnvironment environment, ExecuteScriptRequest request, ExecutionCallback executionCallback) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Services\Automation\GrpcExecutionService.cs:line 146 at UniversalAutomation.ExecutionService.ExecutePowerShell(Script script, IEnumerable1 parameters, Job job, Schedule schedule, ExecutionCallback callback) in C:\actions-runner_work\universal\universal\src\Universal.Server\Services\Automation\ExecutionService.cs:line 730
at UniversalAutomation.ExecutionService.TryExecute(Job job, Schedule schedule) in C:\actions-runner_work\universal\universal\src\Universal.Server\Services\Automation\ExecutionService.cs:line 342
at UniversalAutomation.ExecutionService.TryExecute(Job job, Schedule schedule) in C:\actions-runner_work\universal\universal\src\Universal.Server\Services\Automation\ExecutionService.cs:line 434
at UniversalAutomation.ExecutionService.Execute(Int64 jobId, Nullable`1 scheduleId) in C:\actions-runner_work\universal\universal\src\Universal.Server\Services\Automation\ExecutionService.cs:line 159 Grpc.Core.RpcException

The script itself is simple, it connects via SSH to remote server and sends some csv files from on prem shared network to the remote server. If it meets a failing condition it is caught and an email is sent by invoking another script to send the email with supplied Body, Subject, To and From properties. I can’t tell if the script is causing this or something is wrong within PowerShell universal. Anyone have any ideas?

Just some quick checking around [1] it looks like some others have had this issue before and it may trace back to a certificate issue with the gRPC connection. Are you using an ssh key to connect to the server or just username/password authentication?

Using Posh-SSH cmdlet New-SFTPSession with a private key string and a username and password. I have a finally block that removes the session when the script is done.

To note, the script runs fine manually both on and off powershell universal. It is just the scheduled script that errors.