Filtering out hidden/system folders in EXO

I am trying to write a script to move messages from a shared mailbox to a shared drive, and I’m filtering it for items that are more than 90 days old. The issue is that when I use Get-MailboxFolderStatistics to get the FolderPath, I don’t want to include the hidden/system folders, like Yammer Root, Recoverable Items, etc. I think I have a list of the hidden/system folders that I might be able to use in a ‘-contains’ command, but I was wondering if there was an easier way to do it.


I can’t test but looking at the help file, there is -FolderScope parameter. Does that help at all?

Not really. It’s just another way to filter. I wish I could use Filter, but even if I could, I would have a lot of statements to use to filter out those hidden/system folders. Our Exchange team doesn’t seem to know how to either.

Why don’t you tell us which categories out of that list you do want?

What I want are the “mail-related” folders that a normal user would see, except for RSS Feeds, Sync Errors, etc. The users of these shared mailboxes all have Full Access, so they would still see those folders in the Folder View, even if they don’t know what they are for. I don’t need those folders, and while I tried putting all the folders that I thought were system/hidden folders and tried doing a simple “if -notcontains” clause, that didn’t seem to work. Not sure why it didn’t, as I’ve used it before with an SCCM script that does a similar comparison. Any ideas/suggestions would be greatly appreciated.

Brian Embree

It’s the etc that gets me, not clear on exactly what you do or don’t want.

With that aside, why not show the code you tried with the simple “if -notcontains” clause? Perhaps just a small change can get you what you want? Please be sure to format any code/errors as code with the preformatted text option (</> icon or ctrl + e)