Many times we need to find number of mailboxes in each database and the size of the database (EDB file) of all servers in an Exchange 2010 environment. With PowerShell, it is fairly simple to grab in a single line.
Get-MailboxDatabase | Select Server, StorageGroupName, Name, @{Name="Number Of Mailboxes";expression={(Get-Mailbox -Database $_.Identity | Measure-Object).Count}} | Format-Table -AutoSize
Export to CSV:
Get-MailboxDatabase | Select Server, StorageGroupName, Name, @{Name="Number Of Mailboxes";expression={(Get-Mailbox -Database $_.Identity | Measure-Object).Count}} | Export-Csv C:\ServerStat-1.csv