Powershell script to view mailboxsize for specific user to a domain RRS feed

  • Question

  • Hi.

    I am looking for a powershellscript to retrieve users that either has a primary or an alias emailadress of "example.com". I also want a table to get their Mailboxsize in MB.

    I have managed to get the info about which user accounts who have this email either as primary or just mailboxaddress, but the mailboxsize always comes back as an empty value.

    Do anyone see something wrong in this script?

    Get-Mailbox -ResultSize Unlimited | Select-Object Name, PrimarySMTPAddress, @

    {Name="EmailAddresses";Expression={$_.EmailAddresses -cmatch "smtp"}}, @

    {label="TotalItemSize(MB)";expression={(get-mailboxstatistics $_).TotalItemSize.Value.ToMB

    ()}} | Where-Object {($_.PrimarySMTPAddress -like "*example.com*") -or

    ($_.EmailAddresses -like "*example.com*")} | Out-String -Width 600 | Out-File c:


    Tuesday, June 11, 2013 9:01 AM

All replies

  • Hi

    I think you may have your client side filtering (Where-Object) in the wrong place, I would put this before Select-Object.  Better still you could use server side filtering which is much quicker:

    Get-Mailbox -Filter 'emailaddresses -like "*example.com*"' -ResultSize unlimited

    Then you can leave out the Where pipeline, also the primary SMTP address will be included with the emailaddresses attribute.

    Cheers, Steve

    Tuesday, June 11, 2013 9:19 AM
  • Something like this maybe:

    Get-mailbox -ResultSize unlimited | where {$_.Emailaddresses -like "*@domain.com"} | Get-MailboxStatistics | Select Displayname,totalitemsize | Export-Csv MailStat.csv -NoTypeInformation

    Martina Miskovic

    Tuesday, June 11, 2013 9:20 AM
  • Martina,

    just get an powershell error:

    Sending data to a remote command failed with the following error message: The WinRM client sent a request to the rem
     WS-Management service and got a response saying the request was too large. For more information, see the about_Remo

    I must admit that I work with hyper-v and not exchange so these commands is pretty greek to me :)

    Tuesday, June 11, 2013 10:44 AM
  • Hi Frank_Iversen,
    Don't know why you got that error.

    Steves suggestion was really good...Did you try it?

    Martina Miskovic

    Tuesday, June 11, 2013 7:51 PM