Post navigation

Find mailbox folders with recently changed content

Mailbox settings can be stored in a number of places inside a mailbox. A number of my scripts use Exchange Web Services to manipulate these settings, usually when there isn’t another way for an admin to manage them on behalf of a user. An example is Office 365’s app launcher, which is currently being updated to v3 for tenants. Because the method of managing the v2 launcher doesn’t work with v3, I had to try and find where the settings are stored. The first step in doing that is changing a setting the way a user does (in this case, OWA) and then looking for changed folders as an indication that the setting is stored somewhere in one of them. I decided to share how I do that.

The folder property PR_LOCAL_COMMIT_TIME_MAX (0x670A) stores the last time an item in the folder has changed. This can be used in a search filter to quickly find all folders that have changed since a specific time. First, I define all the MAPI properties I am going to be using in a search filter or in the results:

For efficiency, you usually only want to return as many properties as you will be using in some way. (It is easier/simpler, though, to return the first class properties, when you will be using a lot of the common properties.) So I define a property set to return only what I need:

After creating a folder view and adding the property set to it, I need to create a search filter. This filter gets all folders (that aren’t search folders) where the last commit time is newer than a date and time:

I then loop through the results. First class properties, even if you manually add them to a property set, can be referenced by the object’s property name, e.g.,
$folder.DisplayName, but all other properties (known as extended properties) are collectively stored in another property. You have to attempt to retrieve a defined extended property from this collection. To do this, you have to define a variable in which the value of the extended property will be stored. If you don’t, you will get an error. Then you call the
TryGetPropertymethod, specifying the defined property you want and, by reference, which variable you want to put its value. For example, such as with the last commit time:

(Using the
[void] type accelerator suppresses the output of the object that is returned, which in this case is just True or False as to whether the extended property is in the collection. It is the same as piping the command to
Out-Null .) While having the folder name is helpful, that alone doesn’t always make it clear where that folder is. Therefore, I also get the path to the folder. But the property stores it as a binary value, so I convert it to a string: