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 https://github.com/gscales/Powershell-Scripts/blob/master/SearchFoldersEnums.ps1

To Run the script use

Get-SearchFolders -MailboxName Mailbox@domain.com

to Get Searchfolder from an Archive

Get-SearchFolders -MailboxName Mailbox@domain.com -Archive

to use EWS Impersonation

Get-SearchFolders -MailboxName Mailbox@domain.com -useImpersonation

Tuesday, January 12, 2016

Reporting on Folder RetentionTag Statistics Exchange 2010-16

Mailbox retention tag application and management are one of the more complex administrative tasks on Exchange from 2010 and one task scripting can be a great help with.

With EWS there are two ways you can deal with retrieving the Retention Tags that have been applied to a Folder or Item. In 2013 and 2016,  EWS returns the retention tags applied to a folder or Item as a Strongly typed property which makes things easier to deal with. In Exchange 2010 you need to access the underlying extended properties for Retention tags (this will also work on 2013 and 2016 because the extended properties are the same).

I've posted up a script module on GitHub here https://github.com/gscales/Powershell-Scripts/blob/master/ReportTagged.ps1 that can do this using the Extended properties so it will work on Exchange 2010 and up.

Report-TaggedFolders  - Creates a Report of the FolderTag applied to each of the Folders in a Mailbox (if they are tagged). To get all the availbile Personal Tags the Exchange Management Shell Get-RetentionPolicyTag cmdlet is used. The script also then uses the Tag retrieved from the folder to report then number of Items in that folder that have that Tag applied and produces a report like


Report-UntaggedFolder - Creates a Report of the Untagged Folder in a Mailbox with the FolderClass, ItemCount and ItemSize.