office 365 thorttling and tracking script execution

Working on a script to get Mobile info from users on Office 365. MS throttles the session and script errors out before finishing (MS closes the remote session).

I get all users on an array $mobile=Get-MobileDevice; Foreach ($phone in $mobile) {getsomeinfo}

Any idea how can i run this script for 1000 users than Close and Reopen a session with 365 and continue where i left ?

Basically run the script on groups of users but track the users that are already processed.

There’s no automated paging, no. You’re going to have to figure out a way to segment your users on your own, such as querying those whose names start with “A,” then “B,” or some other segmentation. I suspect that using Select-Object’s -First and -Skip parameters will still eventually time out.