Scearnio: With a large number of mailboxes in our Exchange Online environment, anytime we run a command where it is get-mailbox -resultsize unlmited, we also run into errors/timeouts due to the amount of time and size it takes.
WorkAround: Use filtering within the get-mailbox command to split the data pull and join them into a Master Variable:
Create Variables
$All = @()
$d = (Get-date).adddays(-730)
Set Filter and Run
$f = “{WhenMailboxCreated -ge ‘$d’}”
$1 = get-recipient -filter $f -resultsize unlimited | select name, windowsliveid,primarysmtpaddress
Change Filter and Run
$f = “{WhenMailboxCreated -lt ‘$d’}”
$2 = get-recipient -filter $f -resultsize unlimited| select name, windowsliveid,primarysmtpaddress
Build the Master Variable to contain both datasets
$All += $1
$All += $2