Filtering emails based on subject

by JasonHopp at 2013-02-20 12:01:36


I have a script that displays the name of a shared mailbox and gives the count of emails at the time of the script. It runs well, but I am unable to filter out the messages that were forwarded or replied to. Here is the meat of the script:

Get-MailboxFolderStatistics "GreatLakes Dropbox" | Sort-Object ItemsInFolder -Descending | where {$_.FolderPath -eq "/Inbox"} | Format-Table Identity,ItemsInFolder | Out-File -append $filename

Can someone help me keep what I have but add some kind of filter so it does not count the messages that have FW: or RE: in the subject.

Thanks for your help
Jason Hopp
by mjolinor at 2013-02-20 14:57:34
For that, you’re going to have to script opening the mailbox and reading the message subjects.

The best way I know to do this with Powershell is via the Exchange EWS Managed API. Glen Scales has an excellent tutorial on using it to automate various admin tasks. It’s not a trivial undertaking, but IMHO well worth the effort for the functionality it exposes once you get a handle on it.!/2012/0 … -list.html
by JasonHopp at 2013-02-21 13:37:05
Thanks, I will give it a shot. I will let you know how it goes.

by JasonHopp at 2013-02-22 08:04:22
I am going to try to get into this, but it looks like it all points to 2013. We are using exchange 2010, is there something specific for 2010, or will this work for 2010 as well as 2013?

Jason Hopp
by mjolinor at 2013-02-22 08:51:45
Works for Exchange 2007, 2010, and 2013.