Archive for December, 2011

I came across an anomaly with the Exchange 2007 Export-Mailbox cmdlet at a customer site recently. It created a major inconvenience for some bulk mailbox exports, so I thought I would share it here. Basically, I was able to generate two different search results depending on whether or not I specified a PST file as target. I’ve since managed to reproduce the behaviour in my own test lab, so the problem appears to be generic and not limited to the specific customer’s environment.

My goal was to export all items that contain the string [blah] (including the square brackets) to a target. If I specify a PST file as the target then all items that contain the specified string are exported to the PST file as expected, e.g.

However if I specify a folder in another mailbox as the target and use the same search string then items matching [blah] are copied to the target as well as all items matching blah (i.e. without the square brackets), e.g.

As you can see, the string passed to the AllContentKeywords parameter is exactly the same in both examples, but the result is different.

I haven’t yet found a reasonable explanation for why this is happening, but it seems that the search behaviour is different depepending on whether or not the cmdlet includes the option to export to PST. For example, a straight delete using export-mailbox (i.e. no target at all) will also match both [blah] and blah:

However combining the delete option with an export to PST will just match on [blah].

My guess is that the PST option somehow causes the cmdlet to use a different search method (or index?). When the PST option isn’t used the cmdlet simply ignores the square brackets (and I guess any other special characters). I haven’t yet found a way to escape the special characters to ensure they are included in all searches. If anyone knows how to do this, please let me know.