Mailbox mails to be remove through shell

Hi,
I need to keep one of the mailbox mails to be reserve present two days only and past mails are to be removed.
I have tried below command from exchange shell but it's not worked out.
Get-Mailbox -identity [email protected] | Search-Mailbox -SearchQuery 'Received:<(Get-Date).AddDays(-2).ToString('MM-dd-yyyy')' -TargetMailbox "[email protected]"
-DeleteContent -loglevel full
Please suggest on this.
Regards,
Kumar N

Try this 
Set-ADserversettings  -Viewentireforest $True
$date = (Get-Date).AddDays(-2).ToShortDateString()
Get-Mailbox  -ResultSize Unlimited | Search-Mailbox -Identity "<mailboxname>"
-SearchQuery "Received:<$($date)" -DeleteContent -Force
#Note: (-2) = deletes all mails 2 days back and keeps emails of only last 2 days
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

  • My Mac has stopped receiving mail. Mail is still coming through to my iPhone and my wife's iPad but is not appearing on my mac. I have mail from today on the phone but nothing newer than 18 Feb on the Mac. I have not touched any settings. Can anyone adv

    My Mac has stopped receiving mail. I have a mac.com address. Mail is still coming through to my iphone and my wife's ipad but nothing is coming through to my imac.I have mail from half an hour ago on the phone but nothing newer than 18 Feb on the mac. Everythng was working fine until recently and I have not touched any settings! Can anyone help?

    So I tried something else recently and it seems to have fixed the issue. My mail is now getting new mail again and refreshing after waking from sleep without having to restart mail. Give it a try and hopefully it will help you too.
    First, make sure your Mailbox List is visible (Shift + Control + M). Then select all of your inboxes, mailboxes, and folders (not just the root folder for nested folders, make sure to select them all). Then under the "Mailbox" menu, select "Rebuild."
    It may take a while to rebuild them all if you have a lot, but like I said it seems to have done the trick for me. I hope that proves to be more of a long-term solution.

  • Mailbox size increased after removing attachments

    Doing a little clean-up on my mail, I noticed my sent mailbox was 1.23 gigs. So, I went in saved several hundred attachments and then tried to remove attachments. It would only let me remove attachments about 5 messages at a time, so I moved over 300 messages that all had attachments to a new folder. After moving them I was able to remove all the attachments at one time.
    But after moving and removing attachments the size of my sent mailbox did not decrease it actually increased by over 400 megs to 1.7 gigs. And the new folder was also very large, at almost 700 megs (even after removing attachments).
    Any ideas how/why this happens? and what can I do to reduce the size of that mailbox?
    I have had the overflow issue before and have been trying to keep and eye on the mailbox sizes and keep them under 1 gig, but this one got by me. My only complaint is mail does not tell you the size of a mailbox in the application, if I was able to check the mailbox size right from the app it would be an easier thing to keep an eye on an everyday basis.
    Any help would be great.. thanks!
    G4 400   Mac OS X (10.3.9)  

    For each mailbox, Mail 1.x stores messages sequentially in an mbox file within the *.mbox package associated with the mailbox -- you can see the files contained in an *.mbox package by ctrl-cliking on it in the Finder and choosing Show Package Contents from the contextual menu.
    When a message is removed from a mailbox in Mail 1.x, the actual message may be completely erased from the mbox file, or it may remain there just marked for deletion in one of the other supporting files within the *.mbox package. In order to reduce the mailbox size when a message is deleted from the middle, the entire mailbox would have to be rewritten to disk every time, which is clearly not practical.
    When attachments are removed from a message, the attachments aren’t actually removed from anywhere. What really happens is that Mail creates a new message without the attachments and deletes the original message... and now you know what it really is that actually happens when a message buried in the middle of the mailbox is deleted...
    My only complaint is mail does not tell you the size of a
    mailbox in the application
    Mail 1.3 sure does. The size of the selected mailbox is displayed in the status bar (View > Show Status Bar). Interestingly enough, that feature is no longer available in Mail 2.x.

  • How can i remove the shell case from cath kidston?

    Hi how can i remove the shell case from cath kidston

    Try:
    items.RemoveAll(s => string.IsNullOrEmpty(s));
    Or you can filter them out using where:
    var noEmptyStrings = items.Where(s => !string.IsNullOrEmpty(s));
    Having fun with custom collections!
    Basics of .NET Collections in C#
    How does it work in C#? - Part 3 (C# LINQ in detail)
    Mark as answer or vote as helpful if you find it useful | Ammar Zaied [MCP]

  • My Apple ID verification e-mails are not coming through to my e-mail account.

    My Apple ID verification e-mails are not coming through to my e-mail account. How can I fix that?

    Hi there Lenore1936,
    You may find the troubleshooting steps in the article below helpful.
    Manage your Apple ID primary, rescue, alternate, and notification email addresses
    http://support.apple.com/kb/HT5620
    -Griff W. 

  • XML parsing through shell scritps

    Hi,
    Am new to scripting.
    Am trying to figure out whether can i use bash scripting to parse an xml file.
    Parsing is not just pulling out information according to the pattern but its more of a generic parsing. I should identify the xml hierarchy and pull of information. It's not a basic parsing stuff. So what you tech guys suggest for this. Will the basic bash scripts be suffice or should i go for expat xml parser or perl parsing or whatever??
    Pls suggest some tools and throw some light in this.
    Any help is appreciated.
    Thanks in advance.

    Hi Karthik,
    WELCOME TO SDN
    please check this link
    http://www.unix.com/shell-programming-scripting/63821-xml-parsing-through-shell-scritps.html
    Best regards,
    raam

  • HT2500 how to alphabetize mailboxes (mail folders) in left column of Mail application

    Does anyone know how to how to alphabetize mailboxes (mail folders) in left column of Mail application? It should be easy, but I can't find a way.
    Thanks.

    Hi sanjampet, that didn't work for me.  I disabled my five email accounts, which made the emails dissappear, all mail folders were still visible, I closed the program.  I reopened the program, re-enabled the email accounts, and all the same folders were all still visible - not in alphabetical order, so frustrating.  One would think apple would have a simple button that could be clicked to put mail box folders into order?  Drag and drop is too difficult for me too due to the number of mailboxes.  Any other thoughts?

  • Mailing photos from iphoto through mail

    When I mail photos from iphoto through mail, it sends the picture at very low resolution regardless of the setting I choose (small, medium, large, actual). How can I send photos to others at viewing or even printing quality? Can I resize the pictures to my specifications as I used to be able to do on my PC? Through ACDSee I could resize to 50% which would be small enough to send quickly but still high enough quality for the recipients to view and even print. Thanks!

    drjoan
    After iPhoto has created a new Mail message have a look at the bottom right hand corner of the Mail Message window - there's another control there for sizing the pics... try play with that one to find the size you require.
    You can access your photos for sending in Mail too. In the New Mail Message Window there's an icon on the toolbar that will show you your iPhoto library.
    Regards
    TD

  • E-mailing photos from iPhoto through Entourage

    I have iPhoto 2 and I am using Panther. When I e-mail photos from iPhoto through Apple Mail, the photos appear directly in the e-mail HTML. When I send them through Entourage, they only appear as attachments. How can I send photos from iPhoto through Entourage with the photos appearing in the HTML body of the e-mail?
    Thanks.

    Since your question is about Entourage, you'll have better luck seeking the answer at the Mactopia forums, but I don't think Entourage works like Mail in this respect.

  • Mac Mail won't remove copy from server

    My mail remains in the ISP's Inbox despite the proper setting in my Mac Mail program to remove copy from server immediately after downloading. Even after I close my mail program, the old mail will not be deleted. I must go to my Inbox via the Net and delete the mail with a global tag/delete.
    This problem began 5 to 7 months ago. Before that the auto deletion worked fine, and it worked fine in older versions of OS X. Is this an ISP compatibility? A bug in the current Mac Mail release? A bug in Tiger?
    I asked my ISP and his first reply said this is one of many bugs in Mac Mail and I should switch to Thunderbird. I'll look at that but I prefer to use Apple software.
    After 4 years I know how seldom Apple debugs Mail and Safari. Does anyone know if an update of Mail is on Apple's schedule?
    iMac and others   Mac OS X (10.4.8)  

    Try changing the setting to After one day or When moved
    from Inbox (and leave it at that), to see whether it’s just the Right > away setting that doesn’t work or that Mail fails to remove messages > from that server no matter what the settings.
    I'll do that.
    BTW, have you actually tried using another mail
    client such as Thunderbird
    to check whether the same happens there as well?
    My ISP, who hosts a university and has a higher percentage of Mac users than most, recommended Thunderbird so I presume it does well here at Ntelos.net
    Once upon a time, for two decades as the active proprietor of the Freeware Hall of Fame, ( www.freewarehof.org ) my 12-hour-a-day hobby was installing and testing applications and utilities. I guess I'm tired, because it no longer sounds like fun.
    iMac and others   Mac OS X (10.4.8)  
    iMac and others   Mac OS X (10.4.8)  

  • Creating user account and setting password in Solaris9 through shell script

    I need to create and set password of user through shell scripts.
    User can be added successfully through "useradd" command but password cant be set through "passwd" command in script.
    Is there any other alternative for the same.

    Hi,
    Did you get the answere for this ? I have the same problem as urs , like I want to creat the users by using useradd and want to hardcode there password in one script.
    But I cant use expect utility which would have made my work easier

  • Reading contents of asm through shell script

    How to read contents of asm through shell script?
    Please paste one small example also.
    Thanks
    Bala

    Hello Bala,
    The ASM contents is not visible from the operating system or its utilities. Only visible to database instances, RMAN, and other Oracle-supplied tools.
    Please see http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/glossary.htm#sthref4105
    Regards,
    Rodrigo Mufalani
    http://mufalani.blogspot.com

  • Removing Viewer Shell from DPS App Builder

    I've finished building my app with Digital Publishing Suite and created my app with DPS App Builder (for Single Edition). Now that I'm testing my development app, I was wondering if there was any way to remove the shell around the app I've built, as it interferes with interactive elements on my page. Is this something that can only be done with the Professional or Enterprise Editions?

    There's no way to remove the menu bar that appears on screen when the reader taps the page content. You have to account for it in your design if it concerns you. Even pro/enterprise customers can't disable it.
    Neil

  • Calling sql through shell script

    How do i call a sql file through shell script in unix ?

    Rahul India wrote:
    export ORACLE_HOME=$ORACLE_BASE/product/10g
    cd $ORACLE_HOME
    set `sqlplus -s <SCHEMA_NAME>/<SCHEMA_PASSWORD> <<EOF
    @r_100.sql
    exit;   
    EOF`THIS SCRIPT IS OK?You'll also need to set ORACLE_SID
    And I don't know why everyone is putting the reference to sqlplus inside a "set" valuation, nor why they are putting the reference to the script in a redirected input stream. All you need is
    sqlplus -s user/password  @r_100.sqlAnd to insure the invironment is correctly set:
    export ORACLE_SID=whatever
    export ORAENV_ASK=NO
    . oraenv
    unset ORAENV_ASK=NO
    sqlplus -s user/password  @r_100.sql

  • How to execute sql-queries through shell scripting in linux?

    How to execute sql-queries through shell scripting in linux?

    http://www.oracle.com/technology/pub/articles/saternos_scripting.html
    Two simple examples:
    #!/usr/bin/env bash
    set_orafra () {
       orafra=`echo 'set heading off
       select name from v$recovery_file_dest;
       exit' | sqlplus -s / as sysdba`
    set_orafra
    echo $orafra
    #!/usr/bin/env bash
    export ORACLE_SID=instance_name
    export ORACLE_HOME=/path_to_oracle_home_directory
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib
    export PATH=/$ORACLE_HOME/bin/$PATH
    $ORACLE_HOME/bin/sqlplus -s <<EOF
    connect scott/tiger@my_instance_name
    INSERT INTO table VALUES (sysdate);
    exit
    EOFEdited by: Markus Waldorf on Sep 17, 2010 12:19 AM

Maybe you are looking for