powershell delete specific emails

we have exchange 2007 running and i want to create a powershell script to delete all messages from a specific mailbox where sender = "USER".  it all points to export-mailbox.  needs some assistance.

i also need a powershell script to delete all emails for a specific mailbox in their deleted items folder
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

assuming you are using the administrator user and you want to search the name@domain.com mailbox

add-mailboxpermission name@domain.com -user administrator -accessright FullAccess


export-mailbox name@domain.com -senderkeywords "user@domain.com" -targetmailbox "administrator" -targetfolder "whatever" -deletecontent:$true

team_ironAuthor Commented:
do you need to specify a target mailbox and targetfolder?
yes you do
Make Network Traffic Fast and Furious with SD-WAN

Software-defined WAN (SD-WAN) is a technology that determines the most effective way to route traffic to and from datacenter sites. Register for the webinar today to learn how your business can benefit from SD-WAN!

You don't need to specify a target mailbox or folder if you do not want to.

See my blog entry on this: http://exchangeshell.wordpress.com/2009/08/10/export-mailbox-for-deleting-content-from-mailboxes/

You can just run  Export-Mailbox "UserMailbox" -Senderkeywords "senderemail" -Deletecontent

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
team_ironAuthor Commented:
that makes sense. i will try that
I stand corrected , thanks Shaun never even thought of removing these parameters

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.