Home » Exchange Server 2010 » Checking Mailbox and Database size using some Powershell commands – Exchange 2010, 2013 & 2016

Translate:

Archives

Checking Mailbox and Database size using some Powershell commands – Exchange 2010, 2013 & 2016

In this blog first we will check with Mailbox size & Statistics and then we will go to Database size…….

 

For Admins its regular task “Environment status check” like

 

Count of User Mailbox in Organization

Number Mailbox in each Database

Mailbox Size & Statistics

First 5 users with huge size of Mailboxes size

To check the Mailbox count for auditing, checking manually it takes much time. And below command can help you to save time.

 

This applies for both Exchange 2010 & 2013

 

Command : (Get-Mailbox).Count

 

MBDBSZ1

 

If your Organization have 1000+ employees use the command same with Result size as Unlimited.

 

Command : (Get-Mailbox -resultsize unlimited).Count

 

MBDBSZ2

 

Interesting…… Great

 

want gathering Individual User Mailbox with Total Item Count, Storage Limit status and users Last logon. Then  below is the command

 

Command :

[PS] C:\>Get-MailboxStatistics -Identity “User Mailbox Name”

 

MBDBSZ3

 

Now List of User Mailboxes hosted in the Database with Display name and TotalItemSize with Storagelimitstatus

 

Command :

[PS] C:\>Get-MailboxDatabase “Database Name” | Get-MailboxStatistics | sort totalitemsize -desc | ft displayname, totalitemsize, itemcount, storagelimitstatus

 

In this if you want to deep dive and want to Identify first 5 or 10 mailbox with huge size of Mailbox below is the command to run

 

Command :

[PS] C:\>Get-Mailbox  | Get-MailboxStatistics | Sort-Object TotalItemSize -desc | Select-Object -First 5 | ft displayname,@{Expression={$_.TotalItemSize.Value.ToGb()};label=”T

otal Mailbox Size in Gb”}

 

MBDBSZ4

 

If you want to check by name the exclude the Get-Mailbox and directly go with Get-Mailboxstatistics and when Prompts for Identity provide user Mailbox name as shown below:

 

Command :

[PS] C:\>Get-MailboxStatistics | Sort-Object TotalItemSize -desc | Select-Object -First 5 | ft displayname,@{Expression={$_.TotalItemSize.Value.ToGb()};label=”Total Mailbox Si

ze in Gb”}

MBDBSZ5

 

First 5 User with huge mailbox size within the specific Database then below is the command:

 

Command :

[PS] C:\>Get-MailboxStatistics -Database “Database Name” | Sort-Object TotalItemSize -desc | Select-Object -First 5 | ft displayname,@{Expression={$_.TotalItemSize.Value.ToGb()};

label=”Total Mailbox Size in Gb”}

MBDBSZ6

 

Now Check the number of Mailbox in each Database

Segregating the number of user hosted on each Database.

 

Command :

[PS] C:\>Get-Mailbox | Group-Object -Property:Database | Select-Object name,count

 

MBDBSZ7

 

Now gathering the details with   Server Name, StorageGroupName, Database Name, Size (GB), Size (MB), No. Of Mailbox, below is the command:

 

Command :

 

[PS] C:\>Get-MailboxDatabase | Select Server, StorageGroupName, Name, @{Name=”Size (GB)”;Expression={$objitem = (Get-MailboxDatabase $_.Identity); $path = “`\`\” + $objitem.se

rver + “`\” + $objItem.EdbFilePath.DriveName.Remove(1).ToString() + “$”+ $objItem.EdbFilePath.PathName.Remove(0,2); $size = ((Get-ChildItem $path).length)/1048576KB; [math]::r

ound($size, 2)}}, @{Name=”Size (MB)”;Expression={$objitem = (Get-MailboxDatabase $_.Identity); $path = “`\`\” + $objitem.server + “`\” + $objItem.EdbFilePath.DriveName.Remove(

1).ToString() + “$”+ $objItem.EdbFilePath.PathName.Remove(0,2); $size = ((Get-ChildItem $path).length)/1024KB; [math]::round($size, 2)}}, @{Name=”No. Of Mbx”;expression={(Get-

Mailbox -Database $_.Identity | Measure-Object).Count}}

 

MBDBSZ8

 

If you want to export below is the command :

 

Command :

 

[PS] C:\>Get-MailboxDatabase | Select Server, StorageGroupName, Name, @{Name=”Size (GB)”;Expression={$objitem = (Get-MailboxDatabase $_.Identity); $path = “`\`\” + $objitem.se

rver + “`\” + $objItem.EdbFilePath.DriveName.Remove(1).ToString() + “$”+ $objItem.EdbFilePath.PathName.Remove(0,2); $size = ((Get-ChildItem $path).length)/1048576KB; [math]::r

ound($size, 2)}}, @{Name=”Size (MB)”;Expression={$objitem = (Get-MailboxDatabase $_.Identity); $path = “`\`\” + $objitem.server + “`\” + $objItem.EdbFilePath.DriveName.Remove(

1).ToString() + “$”+ $objItem.EdbFilePath.PathName.Remove(0,2); $size = ((Get-ChildItem $path).length)/1024KB; [math]::round($size, 2)}}, @{Name=”No. Of Mbx”;expression={(Get-

Mailbox -Database $_.Identity | Measure-Object).Count}} | Export-CSV C:\ServerStat-2.csv

[PS] C:\>

MBDBSZ9

 

Now want to check the list of users hosted in the Database then below is the command

 

Command :

[PS] C:\>Get-MailboxDatabase “DatabaseName” | Get-MailboxStatistics | Sort totalitemsize -desc | ft displayname, totalitemsize, itemcount

If you have more than 50+ users and if you want to export below is the command

 

Command :

[PS] C:\>Get-MailboxDatabase “FBMBXDB01” | Get-MailboxStatistics | Sort totalitemsize -desc | ft displayname, totalitemsize, itemcount >C:\MB.csv

 

MBDBSZ10

 

Ok we are done with Mailboxes.

Last but not least Database Size and free space

Gathering Database Size with New Available New Mailbox Space

 

Command :

[PS] C:\>Get-MailboxDatabase -Status | select Name,DatabaseSize,AvailableNewMailboxSpace

 

MBDBSZ11

 

Checking Database Size

 

Command :

 

[PS] C:\>Get-MailboxDatabase -Status | select ServerName,Name,DatabaseSize

 

MBDBSZ12

 

Great…..

Happy Learning…..

 

Praveen Kumar

MCTS, MCITP | Exchange Server

Publisher @ Techrid.com


Leave a comment

Translate »