Microsoft Exchange 2013
To find the number of mailboxes, simply use the Exchange cmdlets and have Measure-Object count the results:
Get-Mailbox –ResultSize Unlimited | Measure-Object | Select-Object -ExpandProperty Count
Likewise, to find all shared mailboxes, try this:
Get-Mailbox –ResultSize Unlimited -RecipientTypeDetails SharedMailbox | Measure-Object | Select-Object -ExpandProperty Count
And to find only user mailboxes, here is the adjustment needed:
Get-Mailbox –ResultSize Unlimited -RecipientTypeDetails UserMailbox | Measure-Object | Select-Object -ExpandProperty Count