I’m working a project where they’re targeting a pilot group of users for mailbox quota information, and I was requested to put together a Powershell command that allowed them to put together a list of users, gather some information on each one regarding their mailbox usage, and dump that report out to a CSV. Well, it look a little bit of work, trial & error, plus all round Googling, but I’ve come up with the gem that works.
Your input CSV, list.csv, needs only to be 1 column with Row 1 titled Name and the remaining rows as the first/last name of the users you want to gather information on.
Save this file below as report.ps1, and fire it up:
Import-Csv “c:\list.csv” | ForEach-Object -Process {Get-Mailbox $_.Name | Select-Object name,@{n=”Size(MB)”;e = {$MBXstat = Get-MailboxStatistics $_.name; $MBXstat.totalItemsize.value.toMB()}},@{n=”DeletedSize(MB)”;e = {$MBXstat = Get-MailboxStatistics $_.name; $MBXstat.totalDeletedItemsize.value.toMB()}},@{n=”Items”; e = {$MBXstat = Get-MailboxStatistics $_.name ; $MBXstat.itemcount}},@{n=”DeleteItems”; e = {$MBXstat = Get-MailboxStatistics $_.name ; $MBXstat.deleteditemcount}}} | Export-CSV “c:\userstats.csv” -notype
You’ll be able to pull the the total items, both in the mailbox and deleted items dumpster, as well as the size of the mailbox plus deleted items dumpster. If you want to add more rows from either the Get-Mailbox or Get-MailboxStatistics command, its pretty straight forward!
[…] (the example was taken from Memphis Technical Network site) […]