Link to home
Start Free TrialLog in
Avatar of team_iron
team_iron

asked on

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
Avatar of Akhater
Akhater
Flag of Lebanon image

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

then

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

Avatar of team_iron
team_iron

ASKER

do you need to specify a target mailbox and targetfolder?
yes you do
ASKER CERTIFIED SOLUTION
Avatar of shauncroucher
shauncroucher
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
that makes sense. i will try that
I stand corrected , thanks Shaun never even thought of removing these parameters