Link to home
Start Free TrialLog in
Avatar of Andy Andy
Andy AndyFlag for India

asked on

Delete email from user mailbox

Hello Team,

We have exchange 2013,

by mistake some confidential email has been sent to user, fromExchange administrator, please suggest the command to delete the specific email with subject line and mailbox name we know..

from powershell

Thanks,
Andy
Avatar of Emmanuel Adebayo
Emmanuel Adebayo
Flag of United Kingdom of Great Britain and Northern Ireland image

You can use Search-Mailbox cmdlet as below with the account that have Mailbox Import Export Role and the Mailbox Search Role

Search-Mailbox -Identity "username or alias" -SearchQuery 'Subject:" Your query "' -DeleteContent

Regards
Search-Mailbox -Identity "username or alias" -SearchQuery 'Subject:" Your query "' -DeleteContent

ref link:https://www.petri.com/delete-email-from-microsoft-exchange-user-mailboxes-using-powershell
Or You can just EAC select user, go to mailbox delegation and assign full rights for yourself
Then add his mailbox in your Outlook account properties, Advance Tab.
Find email and Delete it WITH SHIFT BUTTON.

Then disconnect mailbox and remove delegation
he said He want to ......from powershell
Avatar of Andy Andy

ASKER

i am getting error :

The target mailbox or .pst file path is required.
sorry this is exact error

WARNING: The Search-Mailbox cmdlet returns up to 10000 results per mailbox if a
 search query is specified. To return more than 10000 results, use the
New-MailboxSearch cmdlet or the In-Place eDiscovery & Hold console in the
Exchange Administration Center.
Try to do without shell, you'll have control what you doing and you'll not delete anything by accident
No we cant take access,, as per security compliance
You shouldn't have to do an overall search, you stated the email was sent to one user, correct?  Input the user's email address in the command

Search-Mailbox -Identity johnDoe@yourdomain.com -SearchQuery 'Subject:" Your query "' -DeleteContent
still same error

WARNING: The Search-Mailbox cmdlet returns up to 10000 results per mailbox if a
 search query is specified. To return more than 10000 results, use the
New-MailboxSearch cmdlet or the In-Place eDiscovery & Hold console in the
Exchange Administration Center.

we have exchange 2013
Hi Andy,

The 'WARNING: The Search-Mailbox cmdlet returns [...]" text is not an error. It is just a notification letting you know about the maximum number of search results.

If you are getting any other errors, verify that you are meeting all requirements mentioned in this article:

http://www.codetwo.com/admins-blog/how-to-delete-email-from-mailboxes-on-exchange-2016-2013-2010-online/?sts=6552

The correct output after running the Search-Mailbox command with the -DeleteContent switch should be something like this:

User generated image
Hope this helps,
CodeTwo
still it did not help, Emmanuel Adebayo, suriyaehnop and code two.. could you please help to give exact command
Could post the screenshot of the error
here the error below


WARNING: The Search-Mailbox cmdlet returns up to 10000 results per mailbox if a
 search query is specified. To return more than 10000 results, use the
New-MailboxSearch cmdlet or the In-Place eDiscovery & Hold console in the
Exchange Administration Center.
The operation couldn't be performed because object
'andy@abc.com' couldn't be found on 'chl.ent.abc.com'.
    + CategoryInfo          : InvalidArgument: (0:Int32) [Search-Mailbox], Man
   agementObjectNotFoundException
    + FullyQualifiedErrorId : [Server=CHLTE307,RequestId=06799d63-a789-469c-92
   4a-56eee61837e3,TimeStamp=12/15/2016 9:56:47 AM] [FailureCategory=Cmdlet-M
  anagementObjectNotFoundException] 3EE42C4B,Microsoft.Exchange.Management.T
 asks.SearchMailbox
    + PSComputerName        : exchangecasarray.abc.com
Hi Andy,

Have you tried providing just the alias of the mailbox you want to search? e.g.:

Search-Mailbox -Identity m.smith -SearchQuery '<your query>' -DeleteContent

Open in new window

yes, after trying this, i am getting that error
"Andy@abc.com could't found"?, what search query you want to perform? "Andy@abc.com" is a mailbox? Try a simple search-mailbox for which item you do confirm exist in the mailbox, just to make sure your query is correct and execute successfully
yes that mailbox is exist and i can see that is working too.. it is my own account
Can you use other "identity" instead of smtp address e.g. Alias, legacyexchangedn

https://technet.microsoft.com/en-us/library/dd298173(v=exchg.160).aspx
ASKER CERTIFIED SOLUTION
Avatar of suriyaehnop
suriyaehnop
Flag of Malaysia 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
thanks
I know this question is closed, but I wanted to add some of my real-world usage and experience.
I use this to remove mail from all mailboxes if something that needs to be retracted is gone from all users mailboxes.

I call it Seek & Destroy
Add-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.E2010
Import-Module ActiveDirectory
Get-Mailbox | Search-Mailbox -SearchQuery {Subject:"Your Conference Calling Card Information:" AND received:11/12/2015} -DeleteContent -Force

Open in new window


If you want to target a mailbox you know what to do since this was in the above comments.