Photo by KML on Pexels.com

Introduction

Microsoft recently announced Exchange Online v2 powershell. It has new type of cmdlets starting with Get-EXO* and one of the example cmdlet is GET-EXOMailbox. These new type of cmdlets help to extract large number of objects much faster than old cmdlets.

At this point, It doesn’t have all exchange cmdlets using new method but we can hope in future that all type of cmdlets will be supported. I tried GET-EXOMailbox myself for 10,000 object and it was able to get detail in less than 2 minutes, which was a surprise.

Installation Steps

Update PowerShellGet

Verify – If PowerShellGet version is less than 2.2.1 then run below command to update PowerShellGet, without that you will get below error during new installation of ExOnlineV2 :

Get-Module -Name PowerShellGet
Install-Module -Name  PowerShellGet -Force

Launch Powershell again, now PowerShellGet version will be 2.2.1 or above.

Get-Module -Name PowerShellGet

Install Exchange Online V2

Run this command in elevated powershell and accept prompts :

Install-Module -Name ExchangeOnlineManagement

As soon as you finish it’s installation, you will get new type of commands.

Connect to Exchange Online Powershell v2

Run these command and pass your credentials when prompted.

$cred = Get-Credential
Connect-ExchangeOnline -Credential $cred -ShowProgress $true

If successful, you will be greeted with below window and now you can run commands :

How to run Get-EXOMailbox command

Check example of Get-EXOMailbox and you will find that Get-EXOMailbox isn’t a true copy of Get-Mailbox, It has some differences and the major are Properties and PropertySets.

-PropertySets accepts these values All, Minimum, AddressList, Archive, Audit, Custom, Delivery, Hold, Moderation, Move, Policy, PublicFolder, Quota, Resource, Retention, SCL, SoftDelete, StatisticsSeedthat you nee

In these 2 examples, you can see that PropertySets are Retention and Minimum and both returned different type of values. It means you can use these different propertysets to extract the necessary information.

You can club multiple PropertySets using comma as well :

Get-ExoMailbox -Identity admin123@learn.onmicrosoft.com -PropertySets Retention, Minimum
Get-ExoMailbox -Identity admin123@learn.onmicrosoft.com -PropertySets Retention
ExternalDirectoryObjectId     : 8bced835-6b99-4a8c-b035-cf5f1feada25
UseDatabaseRetentionDefaults  : False
RetainDeletedItemsUntilBackup : False
SingleItemRecoveryEnabled     : True
RetentionHoldEnabled          : False
EndDateForRetentionHold       :
StartDateForRetentionHold     :
RetentionComment              :
RetentionUrl                  :
OrphanSoftDeleteTrackingTime  :
RetentionPolicy               : Default MRM Policy
RetainDeletedItemsFor         : 14.00:00:00
PS C:\WINDOWS\system32> Get-ExoMailbox -Identity admin123@learn.onmicrosoft.com -PropertySets Minimum

ExternalDirectoryObjectId : 8bced835-6b99-4a8c-b035-cf5f1feada25
UserPrincipalName         : admin123@learn.onmicrosoft.com
Alias                     : admin
DisplayName               : Sourabh Jha
EmailAddresses            : {SIP:admin123@learn.onmicrosoft.com, SMTP:admin123@learn.onmicrosoft.com}
PrimarySmtpAddress        : admin123@learn.onmicrosoft.com
RecipientType             : UserMailbox
RecipientTypeDetails      : UserMailbox
Identity                  : SourabhJha
Id                        : SourabhJha
ExchangeVersion           : 0.20 (15.0.0.0)
Name                      : SourabhJha
DistinguishedName         : CN=SourabhJha,OU=admin123@learn.onmicrosoft.com,OU=Microsoft Exchange Hosted Organizations,DC=IND11111PR01A003,DC=PROD,DC=OUTLOOK,DC=COM
OrganizationId            : IND11111PR01A003.PROD.OUTLOOK.COM/Microsoft Exchange Hosted Organizations/learn.onmicrosoft.com - IND11111PR01A003.PROD.OUTLOOK.COM/ConfigurationUnits/learn.onmicrosoft.com/Configuration
Guid                      : 0e90b4cc-aa1d-4cb4-8d2d-436219ed249a

Ref : https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/exchange-online-powershell-v2/exchange-online-powershell-v2

Thank you for reading and please share your feedback

Advertisement