<

Email statistics including mailbox database quotas

Published on
5,722 Points
922 Views
3 Endorsements
Last Modified:
MAS (MVE)
Exchange Server, Windows Server, Active Directory, Virtualization, Skype for Business Expert.
Email statistics and Mailbox database quotas
You might have an interest in attaining information such as mailbox details, mailbox statistics and mailbox database details from Exchange server. At that point, knowing how to retrieve this information from the Exchange management shell becomes essential.  The purpose of this article is to provide instructions to enable you retrieve this information from your server with ease.  

Mailbox details
When you run the get-mailbox command, you will be provided with a list of attributes that you can use to access any area of interest.  All you need to do at this point is type out get-mailbox | fl and the attribute of interest. For example, if you were interested in knowing the database the mailbox belongs to, you will type the get-mailbox | fl command, you will then notice that database is attribute one on that list, and then you will type the command get-mailbox | fl

For example when you run Get-mailbox command you will see the below details (Listed only important attributes).
1. Database                                         Database it belongs to
2. Use Database Quota Defaults    True/False
3. Server Name                                 Currently mounted server
4. Sam Account Name                     Login name
5. Server Legacy DN                         lygacyExcahgeDN(AD database)
6. Address Book Policy                    Address book policy to get a custom addressbook for specific users
7.RetentionPolicy                             Retention policy
8. Alias                                                Alias
9. Display Name                               Display name
10. Email Addresses                       All the email addresses
11. Primary Smtp Address            Primary email in which all emails send from
Check this for details
https://technet.microsoft.com/en-us/library/bb123685(v=exchg.160).aspx

Mailbox statistics details
You might be interested in retrieving more information about your mailbox.  For example, you might want to know the size of the mailbox, the number of messages that it contains or the last time someone accessed the mailbox. So, you will need to know how to run the mailbox statistics command to retrieve mailbox statistics information only.  The syntax for this will be Get-mailbox Statistics | fl interest. 

For example when you run Get-Mailbox statistics command you will see the below details (Listed only important attributes).
1. Associated Item Count                Things that are “associated” with a folder, usually other file-like   things not visible to users.
2. DeletedItemCount                       Deleted items
3. Display Name                               The name, that would be displayed in the front of your e-mail ID
4. ItemCount                                     Total number of e-mails, contacts, etc.
5. LastLoggedOnUserAccount       Indicates the account last used to log on to the mailbox.
6. LegacyDN                                      Used to help you rename attributes
7.StorageLimitStatus                       Indicates the status of the mailbox capacity
8. TotalDeletedItemSize                 Shows how much space is consumed by all users dumpster files
9. TotalItemSize                               Total space consumed by all files
10. Database                                   Database
11. ServerName                              Server Name
12. IsValid                                        If valid it will show you "True" else "False"
Check this for details
https://technet.microsoft.com/en-us/library/bb124612(v=exchg.160).aspx

Mailbox Database quotas details
When you run mailboxdatabase command you will see mailboxdatabase details only.
For example when you run Get-mailboxdatabase command you will see the below details (Listed only iImportant attributes)
1. ProhibitSendReceiveQuota       coming much larger than planned/mailbox exceeds its highest storage quota
2. ProhibitSendQuota                     Could mean your mailbox databases becoming much larger than planned.          
3. IssueWarningQuota                   Mailbox exceeds its lowest storage quota. For more information, go to
4. RpcClientAccessServer              Client Access Server name
5. MountAtStartup                          Mounted at startup or no
6. Organization                               Organization.
7. ServerName                                Server Name
8. Name                                           Database name
9. LogFolderPath                           Location of the logs saved
10. CircularLoggingEnabled         Circular logging status
11. IsMailboxDatabase                  Mailboxdatabase
12. IsPublicFolderDatabase          Publicdatabase
13. AdminDisplayName                Display name in the console
14. IsValid                                      If it is valid it will show you true else false.
Check this for details
https://technet.microsoft.com/en-us/library/bb124924(v=exchg.160).aspx

Some users/clients require results of command get-mailbox, get-mailboxstatistics and get-mailboxdatabase.
In most cases "UseDatabaseQuotaDefaults" will be enabled and mailbox will inherit the quota from the mailbox database quota. Here I consolidated mailbox quota and mailbox database quota to give you both results as some users will not inherit the mailbox database quota. 

Finally I am piping all the above commands to one script to get an output of get-mailbox, get-mailboxstatistics and getmailboxdatabase commands to get Name, Emailaddress, useDatabaseQuotaDefaults(false or true),TotalItemSize, ProhibitSendQuota, ProhibitSendReceiveQuota,  IssueWarningQuota, DBWarningQuota, DBProhibitSendQuota, DBProhibitSendReceiveQuota in one script/command.




The below script is without formatting  which will give you results of Get-mailbox, Get-mailboxstatistics, Get-mailboxdatabase.
$u = Get-Mailbox 
foreach ($m in $u) {
$TotalItemSize   = @{n="TotalSize";
e={if ( (Get-MailboxStatistics -Identity $m).TotalItemSize.Value) {
(Get-MailboxStatistics -Identity $m).TotalItemSize.Value.ToMB()
} else {"-"}}}
$ProhibitSendQuota= @{n="ProhibitSendQuota";
e={if ( (Get-Mailbox $m).ProhibitSendQuota.Value) {
(Get-Mailbox $m).ProhibitSendQuota.Value.ToMB()
} else {"-"}}}
$ProhibitSendReceiveQuota= @{n="ProhibitSendReceiveQuota";
e={if ( (Get-Mailbox $m).ProhibitSendReceiveQuota.Value) {
(Get-Mailbox $m).ProhibitSendReceiveQuota.Value.ToMB()
} else {"-"}}}
$IssueWarningQuota= @{n="IssueWarningQuota";
e={if ( (Get-Mailbox $m).IssueWarningQuota.value) {
(Get-Mailbox $m).IssueWarningQuota.value.ToMB()
} else {"-"}}}
$DBIssueWarningQuota= @{n="DBIssueWarningQuota";
e={if ( (Get-MailboxDatabase -Identity $m.Database).IssueWarningQuota.Value) {
(Get-MailboxDatabase -Identity $m.Database).IssueWarningQuota.Value.ToMB()
} else {"-"}}}
$DBProhibitSendQuota= @{n="DBProhibitSendQuota";
e={if ( (Get-MailboxDatabase -Identity $m.Database).ProhibitSendQuota.Value) 
{(Get-MailboxDatabase -Identity $m.Database).ProhibitSendQuota.Value.ToMB()} else {"-"}}}
$DBProhibitSendReceiveQuota=@{n="DBProhibitSendReceiveQuota";
e={if ( (Get-MailboxDatabase -Identity $m.Database).ProhibitSendReceiveQuota.Value) {
(Get-MailboxDatabase -Identity $m.Database).ProhibitSendReceiveQuota.Value.ToMB()} else {"-"}}}
get-mailbox -resultSize unlimited $m | `
select name,PrimarySmtpAddress,UseDatabaseQuotaDefaults,
$TotalItemSize,`
$ProhibitSendQuota,`
$ProhibitSendReceiveQuota,`
$IssueWarningQuota,`
$DBIssueWarningQuota,`
$DBProhibitSendQuota,`
$DBProhibitSendReceiveQuota}

Open in new window


Result below
ee.png
If you want to format as table below is the command with format table.

$u = Get-Mailbox
foreach ($m in $u) {
$TotalItemSize = @{n="TotalSize";
e={if ( (Get-MailboxStatistics -Identity $m).TotalItemSize.Value) {
(Get-MailboxStatistics -Identity $m).TotalItemSize.Value.ToMB()
} else {"-"}}}
$ProhibitSendQuota = @{n="ProhibitSendQuota";
e={if ( (Get-Mailbox $m).ProhibitSendQuota.Value) {
(Get-Mailbox $m).ProhibitSendQuota.Value.ToMB()
} else {"-"}}}
$ProhibitSendReceiveQuota = @{n="ProhibitSendReceiveQuota";
e={if ( (Get-Mailbox $m).ProhibitSendReceiveQuota.Value) {
(Get-Mailbox $m).ProhibitSendReceiveQuota.Value.ToMB()
} else {"-"}}}
$IssueWarningQuota = @{n="IssueWarningQuota";
e={if ( (Get-Mailbox $m).IssueWarningQuota.value) {
(Get-Mailbox $m).IssueWarningQuota.value.ToMB()
} else {"-"}}}
$DBIssueWarningQuota = @{n="DBIssueWarningQuota";
e={
if ( (Get-MailboxDatabase -Identity $m.Database).IssueWarningQuota.Value) {
(Get-MailboxDatabase -Identity $m.Database).IssueWarningQuota.Value.ToMB()
} else {"-"}}}
$DBProhibitSendQuota = @{n="DBProhibitSendQuota";
e={if ( (Get-MailboxDatabase -Identity $m.Database).ProhibitSendQuota.Value) {
(Get-MailboxDatabase -Identity $m.Database).ProhibitSendQuota.Value.ToMB()
} else {"-"}}}
$DBProhibitSendReceiveQuota = @{n="DBProhibitSendReceiveQuota";
e={if ( (Get-MailboxDatabase -Identity $m.Database).ProhibitSendReceiveQuota.Value) {
(Get-MailboxDatabase -Identity $m.Database).ProhibitSendReceiveQuota.Value.ToMB()
} else {"-"}}}
get-mailbox -resultSize unlimited $m | `
select  name,PrimarySmtpAddress,UseDatabaseQuotaDefaults,
$TotalItemSize,`
$ProhibitSendQuota,`
$ProhibitSendReceiveQuota,`
$IssueWarningQuota,`
$DBIssueWarningQuota,`
$DBProhibitSendQuota,`
$DBProhibitSendReceiveQuota | format-table name,PrimarySmtpAddress,UseDatabaseQuotaDefaults,$TotalItemSize,$ProhibitSendQuota,$ProhibitSendReceiveQuota,$IssueWarningQuota,$DBIssueWarningQuota,$DBProhibitSendQuota,$DBProhibitSendReceiveQuota}

Open in new window


Result Below
Result1.pngHope it helps
3
Comment
Author:MAS (MVE)
1 Comment
 
LVL 45

Expert Comment

by:Amit
Nice Article.
1

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Join & Write a Comment

how to add IIS SMTP to handle application/Scanner relays into office 365.
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month