1

I want to delete a certain group of messages from somebody's mailbox. I already have the basic Powershell command ready to go:

Get-Mailbox -Identity jshmoe | Export-Mailbox -SubjectKeywords "VirusWarning" -IncludeFolders "\Inbox" -StartDate "02/24/2010" -DeleteContent

The problem is that Joe Shmoe's "Inbox" is huge, and I know the messages I want to delete are only in the main Inbox folder. However, the above Powershell command appears to crawl all subfolders beneath "Inbox". Is there a way to tell it not to?

1
  • You might want to ask this on ServerFault.com since it's more SysAdmin related.
    – Joe Doyle
    Feb 26, 2010 at 17:59

2 Answers 2

1

You need the -IncludeFolders parameter, look at the examples here. Be aware that you may need to specify the folder name in the different languages your users may be using, e.g. -IncludeFolders "\Inbox","\Bandeja de Entrada" for English+Spanish.

1
  • link is dead "here"
    – Dani
    Feb 26, 2015 at 19:00
1

looks like this was intended behaviour, but a workaround is shown here

essentially you build a variable containing a list of the folders you want to exclude...

$r = [regex]'/';
$exclude = Get-Mailbox -Identity jshmoe | Get-MailboxFolderStatistics | where {$_.folderpath -ne "/" -and $_.FolderPath -ne "/Inbox"} | Select-Object FolderPath | Foreach {$_.folderpath.tostring()} | foreach {$r.replace($_”,”\”,-1)}

then build up your typical Export-Mailbox command with an exclude instead.

You must log in to answer this question.