PoshRSJob icon indicating copy to clipboard operation
PoshRSJob copied to clipboard

Help request: How to handle credential prompt errors.

Open LuisEmilioR opened this issue 8 years ago • 1 comments

I'm using RSJobs to process Exchange Online reports in multiple threads. The problem is that from time to time something happens on the Office 365 side that requires to re type the powershell session credentials, which makes the job stop and finally fail. Sadly despite my efforts on error handling this doesn't seem to throw any exception that I can handle. Is anyone familiar with this? Any way I can capture and handle this error?

WriteStream : Exception calling "GetSteppablePipeline" with "1" argument(s): "Exception calling "PromptForCredential" with "4" argument(s): "A command that prompts the user failed because the host program or the command type does not support user interaction. The host was attempting to request confirmation with the following message: Enter your credentials for https://mail.contoso.com/powershell?ExchClientVer=15.0."" At C:\Users\user\Documents\WindowsPowerShell\Modules\PoshRSJob\Public\Receive-RSJob.ps1:136 char:49

  •         $PoshRS_jobs | Where $ScriptBlock | WriteStream
    
  •                                             ~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,WriteStream

LuisEmilioR avatar Sep 12 '16 13:09 LuisEmilioR

This is a tough one because you cannot step into the runspace to supply the credentials needed when the prompt occurs. In fact it throws the error as soon as this happens because the running command knows that there isn't a way for the user to interactively provide the credentials.

proxb avatar Sep 15 '16 11:09 proxb