Joe McNicholas
Apr 13, 2017Brass Contributor
O365 Script - credentials prompt
Hi All I have long running scripts running against O365 for our tenant. These can take a day or two to complete. During the run of the script, there can be an interuption where the credentials m...
- Apr 13, 2017
That's just a side effect of broken session to Exchange Online and PowerShell's attempt to recconect to it. The best thing you can do is to optimize your script to run as efficiently as possible, using server-side filtering and Invoke-Command in order to reduce the execution time. Apart from that, you can include a check for the session state before running each cmdlet/iteration. An example of such script can be found here: https://gallery.technet.microsoft.com/scriptcenter/Start-RobustCloudCommand-69fb349e
There are some other recommenadations you can find here: https://blogs.technet.microsoft.com/exchange/2015/11/02/running-powershell-cmdlets-for-large-numbers-of-users-in-office-365/