Thursday, January 28, 2016

Enumerating and Reporting on all Search Folders in a Mailbox or Archive with EWS and Powershell

Search Folders are a feature of Exchange that allows you to have a static search based on a particular criteria  across one or more folders in a Mailbox. They can serve a number of different functions within a Mailbox and are often used to provide some of the backend functionality of new features.

None of the Exchange Management Shell cmdlets gives you  a good view of the SearchFolders in a Mailbox so EWS can be particular useful for this. Eg I've put a cmdlet together that will enumerate all the Search Folders in a Mailbox (or Archive is you interested in that) and produce a report of the folder number of Items and Size of those items that match the Search Folder criteria. It will produce a report such as

I've put a copy of this script up on GitHub here

To Run the script use

Get-SearchFolders -MailboxName

to Get Searchfolder from an Archive

Get-SearchFolders -MailboxName -Archive

to use EWS Impersonation

Get-SearchFolders -MailboxName -useImpersonation