How to search and delete an email from the mailbox

hi,
have a hybrid scenario, exchange 2013 and office 365
what command should I use to search and delete an email from the organization mailbox i.e. I do not want that email to be in any users inbox.
I have tried this command but it does not work, it says search-mailbox is not recognized as the name of the command let.
Get-Mailbox -ResultSize unlimited | Search-Mailbox -SearchQuery 'Subject:"Download this file"' -DeleteContent
kindly assist.
Kind Regards, Khuzema R.

Hi Khuzema
This can be accomplished by search-mailbox command
First you need to create a new role group
To Create –  New-RoleGroup “Mailbox Import-Export Management” -Roles “Mailbox Import Export”
Then add the user to the group
To Add user – Add-RoleGroupMember “Mailbox Import-Export Management” -Member Administrator
Search the mailbox
get-mailbox -ResultSize unlimited -IgnoreDefaultScope | search-mailbox -SearchQuery ‘Subject:”virus infected”’ -LogOnly -TargetMailbox administrator -TargetFolder filter -LogLevel Full
Now we need to run the below command to search the infected emails and delete all of them in the whole organization
get-mailbox -ResultSize unlimited -IgnoreDefaultScope | search-mailbox -SearchQuery ‘Subject:”virus infected”’ -TargetMailbox administrator -TargetFolder filter -deletecontent -LogLevel Full
Also you can do a message tracking with the subject and delete them
Get-ExchangeServer | where {$_.isHubTransportServer -eq $true -or $_.isMailboxServer -eq $true} | Get-MessageTrackingLog -Messagesubject “Virus Infected” | Select-Object Timestamp,ServerHostname,ClientHostname,Source,EventId,Recipients
| Sort-Object -Property Timestamp
I have written a blog with regards to the same. You can always refer this which might mostly  help you in your scenario
http://exchangequery.com/2014/10/16/steps-to-delete-circulated-suspicious-emails-with-search-mailbox/
Thanks 
Remember to mark as helpful if you find my contribution useful or as an answer if it does answer your question.That will encourage me - and others - to take time out to help you Check out my latest blog posts on http://exchangequery.com Thanks Sathish
(MVP)

Similar Messages

  • On my ipad mini, when I delete an email from the inbox (and it goes into Trash), it immediately deletes that email from the server (ATT/Yahoo).  I've called support for both ATT and Apple and can't find a way to have the emails remain on the server.

    On my iPad Mini, when I delete an email from the inbox (and it goes into Trash), it immediately deletes that email from the server (ATT/Yahoo).  I've called support for both ATT and Apple and can't find a way to have the emails remain on the server. 
    My husband and I share an email address and if he misses a day checking email on his notebook, he doesn't receive the items that I have sent to Trash on my iPad Mini.
    Appreciate suggestions.
    [The curious thing is, if I "move" the deleted emails from Trash on my iPad Mini into the Inbox, I can go to my notebook, open my online email and they are back in my ATT/Yahoo Inbox.]

    Is your Yahoo account set up as POP3 or IMAP?

  • I previously had PS CS5 Trial installed but removed it using both Control Panel Programs and deleting all files from the CS5 directory on Program Files.  I then installed a purchased product from Adobe disc using the serial number on the case.  But when I

    I previously had PS CS5 Trial installed but removed it using both Control Panel Programs and deleting all files from the CS5 directory on Program Files.  I then installed a purchased product from Adobe disc using the serial number on the case.  But when I try to launch it, I get a screen headed Photoshop CS5 Extended Trial.  It asks for the serial number and says that my trial has expired.  It rejects the serial number from the Adobe case saying "This Serial Number is not valid for this product".  It thinks that I still have the expired Trial Version installed.  How do I convince it (the program) that the Trial Version is long gone and the currently installed product was installed with a valid and accepted serial number????

    Let me know how it goes. Go into your Adobe account and register your serial number asap.
    https://www.adobe.com/account/my-products-services.html
    That way, should you lose it or you need support, it is on record that it's yours and you can fetch your s/n it from anywhere.
    There are too may sad stories here, where people forgot and the box is buried or lost.
    Gene

  • Delete an email from the pc,  does not delete the email from the iPad.

    Hi
    When I Delete an email from the pc,  does not delete the email from the iPad.  I'm not able to find a setting to fix this.  Does it mean I have to manually delete the emails from the iPad? 
    Thank you in advance for your help.

    Thanks, I was told that my Yahoo account has to be setup on the Mac as a POP account.  Can you please let me know what the difference is (in simple terms) between IMAP and POP? 

  • How to setup adobe to send emails from the application?

    How to setup adobe to send emails from the application?

    Click Edit>Preferences and select the Email Account Preferences
    Click Add Account and select “Add other…” or if you use Gmail or Yahoo mail, select the appropriate choice for it.
    Enter your Email Account info and then click “Advanced Settings” and configure your incoming and outgoing mail settings per your email account in Outlook, Thunderbird or mail service.
    Click OK, and click Add. The new Email Account will now appear in your listed accounts.
    Click the new account and click “Make Default”
    The checkmark will indicate the new account is set as the default Email Account for Reader.

  • Iphoto quit suddenly and deleted todays photos from the MacBook and the phone.  Is there any way to retrieve these precious photos?  are they on my sd card in the phone?

    Iphoto quit suddenly and deleted todays photos from the MacBook and the phone.  Is there any way to retrieve these precious photos?  are they on my sd card in the phone?

    If they are in an iPod backup, then restore another iPod, iPhone or iPad from that backup

  • Searching and deleting duplicate emails

    Does anyone have a reliable way to search for and delete duplicate email?

    Andreas- Thanks for your kind message - i had high hopes for the software because it looked beautiful. I don't know why the headers should be the same - i would think everything about these messages is completely the same - they have to be clones. . . i don't get why they would be different.
    I had seen that other page, but frankly, not being code savvy, i have no idea how to implement that little bit of text - in terminal, into a script - i know it's not yours, but how would i run that bit of code?
    Thanks so very much!

  • HOW TO USE FUNCTION Deletion of Requests from the Change Log IN PRCSES CHAN

    Respected all
    i used Deletion of Requests from PSA from the prcess chain and found good results, now i have only one request at the psa and thus i am doing good space utililisation. but when i am using Deletion of Requests from the Change Log i am not getting any changes in the request of dso. kindly let me know how to use this 2nd function.
    thanks
    abhay

    Hi Mahodaya,
    As per SAp standards its good to delete the requestes that are no longer needed for the delta update and no longer used ffor inti from the change log table and the data is loaded already in to DSO.
    Goto RSPC
    Click on create New PC -> enter the PC name n long descp
    Next we need to define the start process for the PC.Maintain the start variant process.save n come back.
    for deletion of change log we have option in the Other BW Processes -> deletion of requestes from change log
    Once u select the option we get a dialoge box here we need to create the variant for the process enter the process variant n long descp. cick ok.
    Next in the maintenance screen for the deleting the request from change log table will appear.
    Enter the selection patterns to which the requestes should be deleted from the change log.
    In the maintenance screen, select one or more Data Store objects for which requests are to be deleted from the relevant change log tables under Data Store Object column and select theInfo Area of the corresponding Data Store Objects under Info Area
    If you select the first check box exclude selction pattern, this means that del of requests from change log table will be ignored.
    or
    We can delete the requests which are Older than N-number of days (or) date in the above screen. For this one, enter the number of days (or) date in the filed Older than .
    OR
    If we want to select the requests with a certain status then we can also do in the above screen. We can select the following status indicators from the above screen.
    Delete Successfully Updated Requests Only -This status will delete only requests which
    are successfully updated into corresponding Data Store objects.
    Delete Incorrect Requests that were not Updated - This status will delete only incorrect requests which are not successfully updated into the corresponding Data Store Objects.
    Delete Activation Requests only, No Load requests- This status will delete only the activation requests (requests that begin with ODSR_... ). No load requests are deleted.

  • Can i delete my emails from the server using the default mail program in mountain lion?

    how can i delete emails from the server in mail on os 10.8.1?

    Hi, check Mail>Preferences>Accounts, both Mailbox Behaviors & Advanced tab to see those settings.

  • How do I permanently delete an item from the bookmarks bar?

    When I right click and delete a bookmark in the bar, it disappears but comes back after I have shut down my computer and later boot up again.  How do I get rid of it permanently? 

    If by chance you have v10.7 Lion installed not v10.6.8 as your profile suggests, deselect Safari in System Preferences > iCloud then try deleting an item from the Bookmark bar.

  • How do I un-delete a website from the drop down menu?

    I deleted a website from the awesome bar before. Now I want that website to appear on the drop down menu again. I visit it almost everyday but I cannot see it on the awesome bar. How can I fix this?

    Hi thankyou,
    If it was removed it may no longer be listed, however if you have visited the site again I am guessing two things are happening if it does not show up:
    #The settings for your url bar have changed, check to make sure that history is checked in the Location bar settings about:preferences#privacy
    #[[Remove websites from the Awesome Bar suggestions]]
    Did this help?

  • TS3899 iPhone 6   Junk box and blocking junk email from the inbox?

    iPhone 6 when I flag my email as junk it will not move into the junk box, instead it stays in the inbox. Also is there any way of blocking junk email from the inbox?

    What if you are connected to another wifi network assuming your are using that when in the office.

  • How do I recover a draft email from the deleted items

    How do I recover a draft email that I accidentally deleted?

    Thank you Franklin.
    I was looking in the trash folder in apple mail... nothing
    looked online in the gmail trash folder... nothing
    but then there it was in the trash folder of gmail.  Thank goodness.  Plus a save every few minutes as well.
    also online there is a second trash folder with a lable of IMAP and there are the saved drafts in there.
    Thanks for pointing this out good use of shift command 4

  • How to drag and drop an email from Outlook Express (with example code)

    Hi,
    It is possible to drag a mail from Outlook Express and drop it on the desktop, and the file created is a .eml, which is a text file.
    If I drop it into a Java application, no DataFlavor is provided to make the data transfer possible.
    As the data to transfer is a text, it should be possible to drop it.
    How to make a DataFlavor available and recover the text as a stream of characters?
    Example code
    The small application below shows the MIME type of the data that is about to be dropped. If you drag an icon from the desktop, a type will be displayed; if you drag an Outlook Express mail, no type will be displayed.
    Thanks.
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.datatransfer.DataFlavor;
    import java.awt.dnd.DropTarget;
    import java.awt.dnd.DropTargetDragEvent;
    import java.awt.dnd.DropTargetDropEvent;
    import java.awt.dnd.DropTargetEvent;
    import java.awt.dnd.DropTargetListener;
    import java.util.List;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JTree;
    public class TestSDN extends JFrame {
        void run () {
            JLabel lab = new JLabel();
            lab.setPreferredSize (new Dimension (100, 100));
            lab.setOpaque(true);
            lab.setBackground(Color.RED);   
            getContentPane().add (lab);
            new DropTarget(lab, new DropTargetListener(){
                public void dragEnter(DropTargetDragEvent dtde) {
                    System.out.println("dragEnter DataFlavors="+dtde.getCurrentDataFlavors().length);
                    for (DataFlavor df: dtde.getCurrentDataFlavors())
                        System.out.println("DataFlavor MIME type="+df.getMimeType());
                public void dragExit(DropTargetEvent arg0) {
                public void dragOver(DropTargetDragEvent arg0) {
                public void drop(DropTargetDropEvent arg0) {
                public void dropActionChanged(DropTargetDragEvent arg0) {
            pack();
            setVisible (true);
        public static void main(String[] args) {
            new TestSDN().run();
    }Edited by: JavaGame on Jan 29, 2009 9:56 AM
    Edited by: JavaGame on Jan 29, 2009 9:57 AM

    It might just be Microsoft not using standards? I remember having a similar situation - I had an application that could have a zip entry fron 7-zip drag-and-dropped into it (came over as plain text, or maybe an InputStream, can't remember), but when you drill into a zip file with Windows (Vista at least), and try to drag-and-drop a zip entry from Windows Explorer, Java shows no dataflavors available. I just assumed Microsoft wasn't exporting the zip entry in any standard format (such as plain text).
    Sorry, I know that wasn't very helpful, just thought I'd share a similar experience. :)

  • How to search and delete repeated elements in a vector

    Hi again,
    In a class of my application, it needs to check in a vector (A), if there are repeated elements, if it founds one, then it is replaced for a *. then the elements different from * are copied into a new vector(Aa). the code is the following:
    //here are defined the components Textfield, etc
    public void Bconj_Action(Object target)
              int idx = 0;
              int tokenCount;
              String var="";
              String var2="";
              String A[] = new String [50];
              String Aa[] = new String [50];
              String message = (TxtA.getText());
              StringTokenizer st = new StringTokenizer(message,",");
              tokenCount = st.countTokens();
              while (st.hasMoreTokens())
                   A[idx] = st.nextToken();
                   idx++;
              //Recorre vector A en busca de repetidos     
              for(int n=0;n<tokenCount-1;n++)
              for(int m=n+1;m<tokenCount;m++)
              if (A[m]==A[n] && A[n]!="*")
                   A[n]="*";
              //Recorre nuevamente el vector A buscando los diferente a * que seran copiados al vector Aa
              int o = 0;
              for (int n=1;n<tokenCount;n++)
              if(A[n]!="*")
              Aa[o]=A[n];
                   o++;
              for (int i=0;i<tokenCount; i++)
                        if (i==0){
                        var=Aa;}
                                  else{
                                  var = var + "," + Aa[i];}
                   TxtA.setText("");
                   TxtU.setText(var);
    when I run it, and I enter to the prog 1, it don't show me nothing, when I enter 1,1 it shows me 1,null and so on.
    do you have any ideas of what is happening.
    Thanks in advance.

    Two things I would point out to you:
    Its possible that the way you are comparing the Strings is causing a problem for you.
    if (A[m]==A[n] && A[n]!="*")
    A[n]="*";
    }A[m] and A[n] are two Strings so you should compare them using
    A[m].equals(A[n]).So the if statement should look like this:
    if (A[m].equals(A[n]) && !A[n].equals("*"))
    A[n]="*";
    }And second:
    When you copy the unique elements over to array Aa you may be copying less that tokenCount elements. You are actually copying o elements.
    The final for loop could be modified like this:
    for (int i=0;i<o; i++)
    if (i==0){
    var=Aa;}
    else{
    var = var + "," + Aa[i];}
    TxtA.setText("");
    TxtU.setText(var);
    } Thus it prints only the unique elements found rather than the whole array which may contain nulls.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for

  • Help me with XSLT 2.0

    I tried to transform from xml to xml using xslt2.0 on oracle 10g r2. Based on the fact that whenever I added xslt 2.0 features such as "xsl:function","xsl:for-each-group" to stylesheet, oracle 10g gives me an error "LPX-00602: Invalid child element '

  • Vista UAC - handle privileges elevation

    Hi guys, I've been having some trouble with one of the application I have to maintain. Some things that might be needed in order to understand my needs: - it is a java web start application - it embbeds a few Windows applications that we did not deve

  • DVD Plus or minus RW?

    I want to back up my iPhotos and documents using a Burn Folder in the Finder. Is there any advantage to one of these formats – DVD+R or DVD-R – over the other?

  • Track Table History

    Hi, I need to maintain history of TABLE_AA into TABLE_BB. Whenever a column is updated on TABLE_AA, the old record needs to be inserted into TABLE_BB (for history purpose). I am trying to achieve this using a trigger on the table AA but I am getting

  • Help copying a video I took with my iPad 2 please!

    I took two videos using my iPad 2. One video (the longer one -- about 34 minutes) is in my photo stream and I can copy it to my iTunes library and to my PC. The other video is only about 3 minutes. I shows up under "home videos" when I connect the iP