how to get mailbox statistics with primary smtp address instead of display name
i need to produce a report of mailbox stats (totalitemsize) and associated primary stmp address (not displayname) for ~12k user mailboxes. what's the most efficient way to generate this list?
September 15th, 2011 11:31pm
why don't you pull everyone in the organizaton and filter out using excel. here is the script i wrote to export mailbox stats. let me know if you need help modifying it.
------------------------
Add-Content "samaccountname,displayname,title,department,totalitemsize,itemcount,database,servername" -Path c:\Mailbox_stats_export.csv
sleep 10
$allmailboxes = get-mailbox -resultsize unlimited
foreach ($user in $allmailboxes) {
$samaccountname=$user.samaccountname
$aduser = get-user $samaccountname
$statuser = Get-MailboxStatistics $user
$title = $aduser.title
$title = $title.replace(",","-")
$department = $aduser.department
$department = $department.replace(",","-")
$displayname=$statuser.displayname
$totalitemsize=$statuser.totalitemsize.value.tomb()
$itemcount=$statuser.itemcount
$database=$statuser.database
$servername=$statuser.servername
Add-Content "$samaccountname,$displayname,$title,$department,$totalitemsize,$itemcount,$database,$servername" -Path c:\Mailbox_stats_export.csv
}Z-Hire -- Automate IT Account creation process ( AD / Exchange / Lync )
Z-Term -- Automate IT account termination process ( AD / Exchange )
Free Windows Admin Tool Kit Click here and download it now
September 16th, 2011 12:02pm
Hi csp,
You can use this to get the report (this is for all the mailbox users):
Exchange 2007:
$Report=@()
Get-mailbox –resultsize unlimited| foreach-object{
$DisplayName=$_.DisplayName
$SmtpAddress=$_.PrimarySmtpAddress
$TotalItemSize=(get-mailboxstatistics –identity $DisplayName ).TotalITemSize
$obj=new-object System.Object
$obj|add-member -membertype NoteProperty -name "PrimarySmtpAddress" -value $SmtpAddress
$obj|add-member -membertype NoteProperty -name "TotalItemSize" -value $TotalItemSize
$Report+=$obj
}
$Report|export-csv c:\report.csv -notype
Exchange 2010 SP1:
$Report=@()
$mailbox=Get-mailbox –resultsize unlimited
$mailbox| foreach-object{
$DisplayName=$_.DisplayName
$SmtpAddress=$_.PrimarySmtpAddress
$TotalItemSize=(get-mailboxstatistics –identity $DisplayName ).TotalITemSize
$obj=new-object System.Object
$obj|add-member -membertype NoteProperty -name "PrimarySmtpAddress" -value $SmtpAddress
$obj|add-member -membertype NoteProperty -name "TotalItemSize" -value $TotalItemSize
$Report+=$obj
}
$Report|export-csv c:\report.csv -notype
This will get a report at this path: c:\report.csv.
Thanks,
Evan
September 20th, 2011 6:22am