Solved

Exchange 2010 get-mailbox and get-mailboxstatistics

Posted on 2016-08-06
10
750 Views
Last Modified: 2016-08-09
Hi,
I am trying to do some auditing to get all mailboxes primary email addresses , aliases and mailbox sizes.
I have run below script and get primary and aliases email addresses, but it does not give me mailbox sizes.
Get-Mailbox -ResultSize Unlimited |Select-Object DisplayName,ServerName,PrimarySmtpAddress, @{Name=“EmailAddresses”;Expression={$_.EmailAddresses |Where-Object {$_.PrefixString -ceq “smtp”} | ForEach-Object {$_.SmtpAddress}}}, @{Name="TotalSize"; Expression={get-mailboxstatistics $_.displayname | Select-object TotalItemSize}} | Export-CSV c:\temp\smtp.csv

Open in new window

0
Comment
Question by:jzrobbie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 26

Expert Comment

by:-MAS
ID: 41745387
Please check my article which will give you name, PrimarySmtpAddress, DatabaseQuotaenabled, TotalItemSize, ProhibitSendQuota, ProhibitSendReceiveQuota, IssueWarningQuota, DBIssueWarningQuota, DBProhibitSendQuota, DBProhibitSendReceiveQuota
https://gallery.technet.microsoft.com/exchange/Email-statistics-including-e9cb1b26
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 41745439
Try changing $_.displayname to simply $PSItem
I believe there's a common property between those two cmdlets, so it should work...
0
 
LVL 26

Expert Comment

by:-MAS
ID: 41745652
You can try this if you want to pipe get-mailbox and get-mailboxstatistics together
Get-Mailbox -ResultSize Unlimited | sort-object | Select-Object DisplayName, Alias, PrimarySMTPAddress,EmailAddresses,@{n="MailboxSizeMB";e = {$MBXstat = Get-MailboxStatistics $_.Displayname; $MBXstat.TotalItemSize.Value.ToMB()}}

Open in new window

0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

Author Comment

by:jzrobbie
ID: 41745959
@MAS, Thank you for the script. but How can I export to CSV file without adding multiple headers?
I have modified your script a bit , but it shows the item size is "-", still can't figure out why.

Get-Mailbox -ResultSize Unlimited -server NXT17|
Select-Object DisplayName,ServerName,PrimarySmtpAddress, `
@{Name=“EmailAddresses”;Expression={$_.EmailAddresses |Where-Object {$_.PrefixString -ceq “smtp”} | ForEach-Object {$_.SmtpAddress}}}, `
@{Name="size";Expression={if ((Get-Mailboxstatistics $_.alias).TotalItemSize.Value)`
{(Get-Mailboxstatistics $_.alias).TotalItemSize.Value.ToMB()}else{"-"}}} |
more

Open in new window

0
 

Author Comment

by:jzrobbie
ID: 41745968
@sirbounty

Changed to $PSItem ,it still shows blank output for TotalItemSize column
Capture.PNG
0
 
LVL 26

Accepted Solution

by:
-MAS earned 250 total points
ID: 41745971
If you want to export you can use this
Get-Mailbox -ResultSize Unlimited | sort-object | Select-Object DisplayName, Alias, PrimarySMTPAddress,EmailAddresses,@{n="MailboxSizeMB";e = {$MBXstat = Get-MailboxStatistics $_.Displayname; $MBXstat.TotalItemSize.Value.ToMB()}} | Export-Csv C:\temp\smtp.csv

Open in new window

0
 

Author Comment

by:jzrobbie
ID: 41745980
@MAS

It worked!!!

Sort-Object dose the job.

Can you tell me why we need to sort the output before piping to get-mailboxstatistics?
0
 
LVL 67

Assisted Solution

by:sirbounty
sirbounty earned 125 total points
ID: 41746145
Depending on your powershell version (v3 and above support $PSItem) - you may still need to use $_
0
 

Author Comment

by:jzrobbie
ID: 41748195
Thank you guys for the help, problem solved.
0
 
LVL 12

Assisted Solution

by:Benjamin Voglar
Benjamin Voglar earned 125 total points
ID: 41748717
I am using this script to get statistic:

just for info ;)

$Mailboxes = Get-Mailbox -ResultSize Unlimited
 foreach ($Mailbox in $Mailboxes)
 {
 $Mailbox | Add-Member -MemberType “NoteProperty” -Name “MailboxSizeMB” -Value ((Get-MailboxStatistics $Mailbox).TotalItemSize.Value.ToMb())
 }
 $Mailboxes | Sort-Object MailboxSizeMB -Desc | Select PrimarySMTPAddress, MailboxSizeMB

#REM – to export this out — do the following ;) enjoy (see the part where it says “Select” you can add additional fields like ALIAS etc to this)

$Mailboxes = Get-Mailbox -ResultSize Unlimited
 foreach ($Mailbox in $Mailboxes)
 {
 $Mailbox | Add-Member -MemberType “NoteProperty” -Name “MailboxSizeMB” -Value ((Get-MailboxStatistics $Mailbox).TotalItemSize.Value.ToMb())
 }
 
$nname="MailBoxSize"
$date=(get-date).dayofyear
$path="c:\IT\"
$prefix=".csv"
$exportname=$path+$nname+$date+$prefix

$Mailboxes | Sort-Object MailboxSizeMB -Desc | Select DisplayName, PrimarySMTPAddress, MailboxSizeMB | Export-Csv -NoType $exportname

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
how to add IIS SMTP to handle application/Scanner relays into office 365.

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question