# Items and Folder count

**URL:** <https://forums.powershell.org/t/items-and-folder-count/1554>\
**Category:** PowerShell Help\
**Created:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/items-and-folder-count/1554 "2011-12-31T18:30:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![archives](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@archives](https://forums.powershell.org/u/archives)\
**Post date:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/items-and-folder-count/1554/1 "2011-12-31T18:30:00Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:57pm UTC](https://forums.powershell.org/t/items-and-folder-count/1554/2 "2024-05-16T20:57:59Z")

</div>

Closed on May 16, 2024, 8:57pm UTC


