Tuesday, November 10, 2015

Overcome Throttling issues with Office 365 for your PowerShell Scripts

I am writing this post today to point you to the latest Exchange Team blog post, explains how to overcome throttling issues when running PowerShell cmdlets for large numbers of users in Office 365.




Its quite common that we generate reports or apply changes to large number of users in Office 365 as a part of Operations and need to wait for hours to get the results. We all know about the throttling limits that exist with Office 365 and sometime the script breaks and makes us to start from the scratch. Finally, Microsoft team published a blog post to overcome this issue.

By using the the help of Script blocks and Invoke-command cmdlet we can construct PowerShell Scripts that returns the required data without much issues on time and also a great PowerShell script "Start-RobustCloudCommand script" is shared to us that makes our job a lot easier.

More information is available in the below EHLO blog post,

Review here: Running PowerShell cmdlets for large numbers of users in Office 365

I have personally used this script for a recent requirement to disable clutter for a large set of users and it did worked well.

Here is the example,

Set-ExecutionPolicy Unrestricted

$cred = Get-Credential

$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $cred -Authentication Basic -AllowRedirection

$importresults = Import-PSSession $session 


$Mailboxes = invoke-command -scriptblock {Get-mailbox -resultsize unlimited | select-object -property Displayname,PrimarySMTPAddress,Identity} -session (get-pssession)

$cred = get-Credential

.\Start-RobustCloudCommand.ps1 -Agree -Credential $cred -recipients $Mailboxes -logfile C:\temp\out.log -ScriptBlock {Set-Clutter -identity $input.PrimarySMTPAddress.tostring() -enable:$false} –interactive

This guidance is great and it will reduce some of our support cases related to throttling.

No comments:

Post a Comment