Back to blog

Working with the all-new Exchange Online Cmdlets

Jan 23, 2020 by Emma Robinson

Times have moved on a lot since the beginnings of PowerShell, and Remote PowerShell (RPS), which is still used by many for reporting on Exchange On-prem and Online. And as Tony Redmond outlined in his sessions at Microsoft Ignite in November, and Ignite the Tour London last week, Remote PowerShell, first released in 2010, is really starting to show its age. In this blog, we will highlight some of the key takeaways of this session, pointing to helpful resources for improving your experience with the new cmdlets backed by RESTful APIs.

Do you use PowerShell to run reports on Exchange Online in large or complex tenants? If so, our upcoming webinar is a must-watch. Co-hosted by two PowerShell experts and long-time Microsoft MVPs Vasil Michev and Ingo Gegenwarth Working with the new Exchange Cmdletswill include practical advice and demonstrations for running the all-new cmdlets against large Office 365 tenants. Listen to the session on-demand now.

There are a few reasons why you might see unreliable performance with Remote PowerShell when running against Exchange Online. Due to the nature of the cloud, you have an increased lack of control over connection stability – this can lead to network outages, domain controller changes, throttling, drops, and disconnects – resulting in timeouts and errors.

In this super speedy 15-minute session, Tony explored the arrival of 9 new cmdlets for Exchange Online and demoed the these against 30 mailboxes to show speed differences.

All of the potential obstacles above serve to fuel excitements over the latest release: 9 Exchange Online cmdlets backed by RESTful APIs, designed to be faster and more efficient. If you have good eyesight you might be able to see some details for these new additions in the slide featured in the photo above, if it all seems a little blurry to you – I have replicated and elaborated below:

  • The new PowerShell module for Exchange Online management is stateless – which means it has no affinity to any specific mailbox server. ‘Fun’ fact, there are over 250,000 Exchange servers – meaning that affinity is not good news for speed or stability.
  • Rather than failing completely, the new cmdlets can retry and resume from the point of the last failure. This ability solves some of the issues we highlighted earlier as causes for failed scripts.
  • They are optimized for Azure Active Directory queries which means they connect to AAD much faster.
  • They offer intelligent property management. Exchange cmdlets return a high volume of properties which can slows things down, especially if you’re looking for something more specific. These new cmdlets prompt you to think about your query more carefully and only request what you need.
  • At the moment, only 9 cmdlets have been upgraded.
    • The upgraded cmdlets are:
      • Get-Mailbox.
      • Get-CASMailbox.
      • Get-Recipient.
      • Get-RecipientPermission.
      • Get-MailboxPermission.
      • Get-MailboxFolderPermission.
      • Get-MailboxStatistics.
      • Get-MailboxFolderStatistics.
      • Get-MobileDeviceStatistics.

As you can see, all the of the upgraded cmdlets are all ‘Get’ not ‘Set’. Now, 9 cmdlets may not seem all that impressive, given that there are around 700 Exchange cmdlets in total, but this is an iterative process and the first release has focused on some of the more popular cmdlets. For example, Get-MailboxStatistics was the first Exchange cmdlet created, and it remains one of the most used commands, and the basis for many useful scripts. It returns a selection of details outlining, no big surprises here, mailbox statistics for a user, including DisplayName, ItemCount, and LastLogonTime.

If you’re looking for scripts to help solve a specific use case – why not head over to our sister site Practical 365, as there is a whole PowerShell section with scripts for Office 365 and Exchange.

Some considerations

In his session, Tony went on to explain some crucial ‘gotchas’ for the new cmdlets. This included the data format – the new cmdlets return data differently, output is ordered alphabetically rather than ordered by the whencreated property. Similarly, the date output is in a US format, which could be confusing for users from elsewhere, like many of the London audience at this event. OAuth is the only authentication mechanism, there is no basic auth. There are also some important upgrade steps that need to be made before you can get started, the installation process is covered in detail by Tony’s Petri article on the Exchange Online Rest-based cmdlets.

The demo

In order to demonstrate the speed and efficacy of the new additions, Tony tested Get-Mailbox live on stage. He ran it against 30 mailboxes, each located on different mailbox servers, and compared to speeds reached using the old cmdlets. One of the important take-aways for using the new cmdlets is that they take a while to get going, increasing in speed the more times you use them. This was demonstrated by running the same command on the same items three times, and watching the time to completion drop significantly, becoming three times faster by the final round. Another point to note from the demo is that when one script failed (conference Wi-Fi) it restarted automatically, reducing the amount of intervention required.

See the cmdlets in action

On February 5th | 16:00 GMT | 11:00 ET, Quadrotech will be hosting a webinar focused on ‘Working with the new Exchange cmdlets’ – Listen on-demand now. As the title suggests, the session will be highly practical, with hands-on technical advice from experts in PowerShell and Exchange, Microsoft MVPs Vasil Michev and Ingo Gegenwarth.

This is a must-watch session – listen on-demand now!

If you are not able to make the session live, register your details and we will send you a copy of the recording. We will also be holding a detailed Q&A, so if you have any questions you’d like addressed in the session – you can submit them when you register, or there will be a chance to ask them live too!