Exchange 2010 Power Shell script delete content issue
Posted on 2013-01-31
As a result of trying to do 15 things at once and not paying closer attention to my cmd line syntax, I made a little booboo.
Goal: To delete all of my messages in my Deleted Items on the 2010 Exchange server using Exchange Power Shell (PS). That's it! No more, no less.
Syntax used: Search-Mailbox -Identity "Peter Mitchell" -TargetFolder "\DeletedItems" -LogLevel Full -DeleteContent
Issue: Being used to syntax in Exchange 2007, I had what I thought was the correct syntax for 2010. However as a result of assumption and not paying close, undivided attention I did not.
Result: My entire Inbox/subfolders and calendar wiped out clean. Not my intention for that to happen as the intention was to ONLY delete the items from my Deleted Items folder.
From there, and as I inadvertently instructed the PS to do, it moved all of my Inbox/subfolders to the ITSupport mailbox and created a new folder called "\DeletedItems" (which I know have learned I inadvertently instructed it to do!). The full path was actually "\DeletedItems\Peter Mitchell-1/31/2013 5:51:16 PM\Primary Mailbox\[Calendar, Contacts,Deleted Items,Drafts,Inbox,Recoverable Items,Sent ITems,Suggested Contacts,SyncIssues,Tasks] (listed in folder tree under Primary Mailbox)
Magic question is....where did I go so wrong? (aside from excessively multi-tasking!)? And what is the correct Exchange PS cmd line syntax to just delete messages from a given folder in a given mailbox?
Any help would be greatly appreciated for this valuable lesson learned!