Forum Discussion
O365 Script - credentials prompt
- 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/
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/
- Joe McNicholasApr 18, 2017Brass Contributor
Thanks for the information, I'll look into using these techniques. Shame there's no simple "silver bullet" here..... :(