Exchange Powershell – Find Mailbox size of users in a Distribution List

0

Hi All,

I recently got a request from a friend asking whether it was possible to find Mailbox size of the users in a Distribution List. And I said, yes definitely it is possible! Why wouldn't it be?

There is virtually everything you can find out about the Exchange environment using Exchange Management Shell. Hence we will be seeing a small script which will achieve what we are planning to do here.

Say that I have a Distribution List called "Finance Team". At first I will have to find out the members of the Distribution List so then I can individually find their mailbox sizes.

$GroupName = Read-Host "Kindly provide the name of the Distribution Group"
Get-DistributionGroupMember $GroupName | Select Name | Export-Csv c:\Members.csv -NoTypeInformation

Let us see what did we do in the above two lines. At first once the script is made to run, it will prompt you for the name of the Distribution Group.

Once you provide the name, it will store it in a variable and then get the members of the group using Get-DistributionGroupMember.

We will select only the name and create a csv file called Members.csv.

$Members = Import-Csv C:\Members.csv
Foreach ($Member in $Members){
Get-MailboxStatistics $Member.Name | Select DisplayName, TotalItemSize
}

In the next step you will import the csv file that we just created into a variable called $Members.

Using Foreach loop, we will find the mailbox size of all the members of the group one by one.

Exchange Powershell - Find Mailbox size of users in a Distribution List

So the final script will look as below.

$GroupName = Read-Host "Kindly provide the name of the Distribution Group"
Get-DistributionGroupMember $GroupName | Select Name | Export-Csv c:\Members.csv -NoTypeInformation
$Members = Import-Csv C:\Members.csv
$Result = Foreach ($Member in $Members){
Get-MailboxStatistics $Member.Name | Select DisplayName, TotalItemSize
}
$Result | Export-Csv C:\Result.csv

Save this a .ps1 file and execute using Exchange Management Shell. I have added another line to export the final result as a csv file for easy maintenance.

Share.

About Author

I am Adil Arif, working as a Senior Technical Support Engineer at Rubrik as well as an independent blogger and founder of Enterprise Daddy. In my current role, I am supporting infrastructure related to Windows and VMware datacenters.

Leave A Reply