Items and Folder count

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of Forums Archives Forums Archives 5 years, 5 months ago.

  • Author
    Posts
  • #6500

    by FrancoisFMD at 2013-01-11 09:05:22

    I'm quite new to this Powershell world and trying my best to learn new tricks but I'm having some sort of a blockage with this one. I need to extract to a file the DisplayName, Item count and folder count for each mailbox. I'm able to get both but separately. I can't seem to be able to join them in a single script. I'm sure this is pretty basic but can't get it to work. Can anyone help?

    by hapklaar at 2013-01-11 16:03:37

    The problem is that you need both get-mailbox / get-mailboxstatistics and get-mailboxfolderstatistics for this output. I have a script I use to extract mailboxinfo you can use for this. I've added FolderIdCount for you and left all my other variables intact:

    $Database = @{n="Database";e={ $stats.database }}
    $DisplayName = @{n="DisplayName";e={ $stats.Displayname }}
    $StorageLimitStatus = @{n="StorageLimitStatus";e={ $stats.StorageLimitStatus }}
    $ItemCount = @{n="ItemCount";e={ $stats.ItemCount }}
    $TotalItemSize = @{n="TotalItemSize(MB)";e={ $stats.TotalItemSize.Value.ToMB() }}
    $TotalDeletedItemSize = @{n="TotalDeletedItemSize(MB)";e={ $stats.TotalDeletedItemSize.Value.ToMB() }}
    $LastLogonTime = @{n="LastLogonTime";e={ $stats.LastLogonTime }}
    $LastLoggedOnUserAccount = @{n="LastLoggedOnUserAccount";e={ $stats.LastLoggedOnUserAccount }}
    $FolderIdCount = @{n="FolderIdCount";e={(get-mailboxfolderstatistics -id $_.alias | select FolderId).count}}

    $mb=get-mailbox -resultsize unlimited
    $mb | foreach-object {
    $stats = get-mailboxstatistics $_
    $_ | select alias, legacyexchangedn, name,$DisplayName, *SMTP*,$Database,$StorageLimitStatus,$ItemCount,$FolderIdcount,$TotalItemSize,$TotalDeletedItemSize,$LastLogonTime,$LastLoggedOnUserAccount
    }

    The bare essentials for you:
    $DisplayName = @{n="DisplayName";e={ $stats.Displayname }}
    $ItemCount = @{n="ItemCount";e={ $stats.ItemCount }}
    $FolderIdCount = @{n="FolderIdCount";e={(get-mailboxfolderstatistics -id $_.alias | select FolderId).count}}

    $mb=get-mailbox -resultsize unlimited
    $mb | foreach-object {
    $stats = get-mailboxstatistics $_
    $_ | select $DisplayName, $ItemCount,$FolderIdcount
    } |export-csv c:\export.txt

You must be logged in to reply to this topic.