Hi All,
Sometimes you may have the need to get information about a folder in a users Exchange 2010 mailbox. For example, lets say you wanted to find information pertaining to a users “Contacts” folder. More specifically, you wanted to know how many contacts a mailbox contains. To find information about a user’s Contacts folder you can simply use the following command:
The Command
get-mailboxfolderstatistics [email protected] -FolderScope contacts
Note: You could also use the alias for the mailbox and several other values instead of the SMTP address as shown above. See the help for the “get-mailboxfolderstatistics” cmdlet for more information.
This command will give you the following information in the contacts folder in a users mailbox:
The Output
RunspaceId
Date
Name
FolderPath
FolderId
FolderType
ItemsInFolder
DeletedItemsInFolder
FolderSize
ItemsInFolderAndSubfolders
DeletedItemsInFolderAndSubfolders
FolderAndSubfolderSize
OldestItemReceivedDate
NewestItemReceivedDate
OldestDeletedItemReceivedDate
NewestDeletedItemReceivedDate
OldestItemLastModifiedDate
NewestItemLastModifiedDate
OldestDeletedItemLastModifiedDate
NewestDeletedItemLastModifiedDate
ManagedFolder
TopSubject
TopSubjectSize
TopSubjectCount
TopSubjectClass
TopSubjectPath
TopSubjectReceivedTime
TopSubjectFrom
TopClientInfoForSubject
TopClientInfoCountForSubject
SearchFolders
Now lets say you wanted the same information for all mailbox but you only wanted select properties to display. For this you could type the following command:
The Command
get-mailbox | get-mailboxfolderstatistics -FolderScope contacts |select identity,name,folderpath,foldertype,ItemsinFolder,foldersize
The command above will only show the properties that have been added after “|select”.
When running this for all mailboxes, it may be way to much information depending on the size of your organization and it will fly by your screen way faster than you can read it. You may notice that you see some red errors because some mailboxes do not contain the folder you are looking for. To have this information in a report that is easy to retrieve and read after the command is run, you can pipe it to a csv file for review. To do this you can type the following command:
The Command
get-mailbox | get-mailboxfolderstatistics -FolderScope contacts |select identity,name,folderpath,foldertype,ItemsinFolder,foldersize | Export-Csv c:\test\AllMailboxContacts.csv
This will output the the information to a csv file called “AllMailboxContacts.csv” in a folder called “test” (create folder before running command) on the c drive. Any errors for mailboxes not containing the folder you are searching for (in this case contacts) will show up in the PowerShell window for your review. All other info will be in the csv file.
As with any PowerShell command you can use the help to find different ways of using the “get-mailboxfolderstatistics” cmdlet to obtain the information you need by typing the following command:
The Command
get-help get-mailboxfolderstatistics
As always, I suggest testing this and any new commands you are using in a lab scenario. Hope this helps!