proxb / PoshRSJob

Provides an alternative to PSjobs with greater performance and less overhead to run commands in the background, freeing up the console and allowing throttling on the jobs.
MIT License
539 stars 87 forks source link

Help request: How to handle credential prompt errors. #98

Open LuisEmilioR opened 7 years ago

LuisEmilioR commented 7 years ago

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

proxb commented 7 years ago

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.