Long Running Office365 Script

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 1 year and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
typody
Posts: 8
Last visit: Sat Dec 10, 2022 11:20 am

Long Running Office365 Script

Post by typody »

Hi,

I have a script that extracts a load of information about mailboxes hosted in Office 365, the script works fine, and I get all the info I need. But when there is a large number of mailboxes, I lose my connection and need to reauthenticate. When I reauthenticate the script continues but skips a load of mailboxes (I assume these are the ones that are failing when the session breaks). Any suggestions of how to keep the connection live?

Thanks in advance
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Long Running Office365 Script

Post by jvierra »

You have to code network operations that are not transacted so that they are restart able. O365 sessions are not restart able. I recommend partitioning your data requests to return only enough data so that you do not time out and if you time out then restart with the block that failed.

Also post in the O365 developer forum to find out if anyone knows of a module that can acquire large amounts of data.

Overall, you should always post subsystem specific questions in a technical forum for that subsystem or service. This forum is targeted at questions about PowerShell and the Windows OS and not at remote subsystems. If the modules used are not part of PowerShell, then start with the module forum and work out from there. That will get you the best answer faster.

O265 Admin sessions will disconnect after 8 hours. Outlook OWA will disconnect after 6 hours. Both want reauthentication which is why the disconnect happens. Without any more info no one will be able to know what timeout you are seeing. Networks can go down or be rerouted which will cause a disconnect then a timeout. There is nothing that can be done with this. It has been a primary issue in networking so no long running processes should be assumed to be completable. Al remote requests have to be programmed to this potential conditioned.

Good luck.
This topic is 1 year and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked