Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save iqwirty/9668136 to your computer and use it in GitHub Desktop.
Save iqwirty/9668136 to your computer and use it in GitHub Desktop.
Gets Exchange mailbox statistics for a list of users specified in a text file. Writes the statistics to an output .csv file.
# Load the Exchange management cmdlets.
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
Add-PSSnapin Microsoft.Exchange.Management.Powershell.Support
# Import all the modules located in:
# %windir%\System32\WindowsPowerShell\v1.0\Modules
ImportSystemModules
$usersFromFile = Get-Content "users.txt"
$userstats = @()
ForEach ($u in $usersFromFile)
{
Write-Host "Processing $u..."
$foundUserStats = Get-MailboxStatistics $u | `
Select DisplayName, TotalItemSize, ItemCount, ServerName, StorageGroupName, Database
$userstats = $userstats + $foundUserStats
}
$userstats | Export-Csv -Path "userstats.csv" -notype
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment