PS: List of mailboxes


Found following power shell script is useful to analyze a particular exchange database contents. Script outputs  total number of mailboxes in a database, the total size of the mailboxes, and the total number of items in each mailbox and average mailbox size and the average number of items each mailbox.
#—————–Start————
#script name: listofmailboxes.ps1
# Retrieve the list of mailboxes from the specified mailbox database
$listOfMailboxes = Get-MailboxDatabase “EXCH-DB” | Get-Mailbox

# Initialize the counter variables to be used
$mailboxCount = 0
$mailboxTotalItemCount = 0
$mailboxTotalSize = 0
$mailboxAverageSize = 0
$mailboxAverageItemCount = 0

# Start loop to count each mailboxes

foreach ($individualMailbox in $listOfMailboxes)
{

# increment the mailbox count by 1

$mailboxCount++

# Get the name of the current mailbox

$individualMailboxName = $individualMailbox.Identity.DistinguishedName
$individualMailboxStats = Get-MailboxStatistics -Identity $individualMailbox

# Get the size of the mailbox in MB and save it in a variable
$individualMailboxSize = $individualMailboxStats.TotalItemSize.value.toMB()
#$individualMailboxSize = $individualMailboxStats.TotalItemSize.value.toGB() shows in GB

# Get the number of items in the mailbox and save it in a variable
$individualMailboxItemCount = $individualMailboxStats.ItemCount

# Add the size of this mailbox to a running total
$mailboxTotalSize = $mailboxTotalSize + $individualMailboxSize

# Add the number of items in this mailbox to a running total
$mailboxTotalItemCount = $mailboxTotalItemCount + $individualMailboxItemCount
}

# Calculate the average mailbox size
$mailboxAverageSize = $mailboxTotalSize / $mailboxCount

# Calculate the average number of items per mailbox
$mailboxAverageItemCount = $mailboxTotalItemCount / $mailboxCount

# Display the results to the user
Write-Host “Total Number of Mailboxes in database: $mailboxCount”
Write-Host “Total Size of Mailboxes:               $mailboxTotalSize MB”
Write-Host “Total Items in Mailboxes:              $mailboxTotalItemCount”
Write-Host “——————-”
Write-Host “Average Mailbox Size:                  $mailboxAverageSize MB”
Write-Host “Average Items per Mailbox:             $mailboxAverageItemCount”

##—————–end————-
OUtput:

Total Number of Mailboxes in database: 139
Total Size of Mailboxes:               94440 MB
Total Items in Mailboxes:              749734
——————-
Average Mailbox Size:                  679.424460431655 MB
Average Items per Mailbox:             5393.76978417266

Show in GB

Total Number of Mailboxes in database: 139
Total Size of Mailboxes:               48 GB
Total Items in Mailboxes:              749749
——————-
Average Mailbox Size:                  0.345323741007194 GB
Average Items per Mailbox:             5393.87769784173

Advertisements

About Robiul

Robiul has 15 years of continuous successful career experience in ICT with extensive background in System Engineering, IT infrastructure design, operations and service delivery, managing IT projects / MIS functions for local and multi-national companies with in-depth knowledge of multiple operating systems as well as construct / manage small to medium size Data Center. Proven ability to design and implement medium to semi-large scale LAN/WAN/WLAN and system infrastructures. Academic qualification: Master of Science in Information Systems. Professional certifications are: MCSE, CCNA, ITIL and FoundStone Security Professional, VCP, NetAPP, CISSP etc.
This entry was posted in Exchange and tagged . Bookmark the permalink.