Invoke-RestMethod failure when using job scheduler in linux

Does anyone know how pwsh and linux handles certificates when using HTTPS? I’m running into an issue when utilizing Invoke-RestMethod through our job scheduler. I do not get an error when I run it directly through the terminal.

 

Error:

Invoke-RestMethod : The remote certificate is invalid according to the validation procedure.

At line:1 char:1

}:HttpRequestMessage) [Invoke-RestMethod], HttpRequestException

  • FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

EXIT STATUS VALUE OF $? THE COMMAND THROUGH POWERSHELL: 0

Are you using PowerShell background Jobs ?

Nope. It’s executed from kornshell.

pwsh -command “Invoke-RestMethod -uri ‘https://blogs.msdn.microsoft.com/powershell/feed/’”

Probably something in your path variable is being changed. Is anything being sourced when the scheduler runs?