SOLVED

Run Exchange Online Powershell script as background job

%3CLINGO-SUB%20id%3D%22lingo-sub-1656532%22%20slang%3D%22en-US%22%3ERun%20Exchange%20Online%20Powershell%20script%20as%20background%20job%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1656532%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20Exchange%20Online%20and%20Powershell%20experts%2C%20I%20have%20a%20script%20that%20fails%20to%20complete%20because%20of%20time-out%20in%20session.%20Therefore%2C%20I%20thought%20of%20running%20it%20as%20a%20background%20job.%20I've%20seen%20some%20articles%20about%20that%2C%20but%20there%20they%20used%20the%20old%20exo%20ps%20modules%20and%20basic%20auth.%20I%20would%20like%20to%20achieve%20that%20using%20ps%20module%20supporting%20modern%20auth.%20Any%20ideas%20about%20that%3F%20Best%20regards%20-%20Ruslan%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1656532%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExchange%20Online%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1657827%22%20slang%3D%22en-US%22%3ERe%3A%20Run%20Exchange%20Online%20Powershell%20script%20as%20background%20job%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1657827%22%20slang%3D%22en-US%22%3E%3CP%3EThe%20V2%20module%20has%20some%20better%20login%20and%20should%20reconnect%20sessions%20automatically%20(for%20a%20time)%2C%20but%20other%20than%20that%20not%20much%20has%20changed%20and%20you%20should%20still%20follow%20the%20same%20old%20recommendations.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1660365%22%20slang%3D%22en-US%22%3ERe%3A%20Run%20Exchange%20Online%20Powershell%20script%20as%20background%20job%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1660365%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F366140%22%20target%3D%22_blank%22%3E%40RNalivaika%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20the%20session%20time%20out%20resulting%20of%20inactivity%2C%20then%20you%20can%20keep%20sending%20from%20time%20to%20time%20a%20request%20to%20the%20exchange%20server%20and%20small%20invocation%20for%20the%20connection%20to%20keep%20the%20session%20active.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Contributor

Hello Exchange Online and Powershell experts, I have a script that fails to complete because of time-out in session. Therefore, I thought of running it as a background job. I've seen some articles about that, but there they used the old exo ps modules and basic auth. I would like to achieve that using ps module supporting modern auth. Any ideas about that? Best regards - Ruslan

3 Replies
Highlighted
Best Response confirmed by RNalivaika (Contributor)
Solution

The V2 module has some better login and should reconnect sessions automatically (for a time), but other than that not much has changed and you should still follow the same old recommendations.

Highlighted

@RNalivaika 

If the session time out resulting of inactivity, then you can keep sending from time to time a request to the exchange server and small invocation for the connection to keep the session active.

 

Highlighted

Using V2 module in combination with new cmdlets in the script solved the timeout issue.