Powershell Command to permanently delete items in ALL users Deleted Items folder older than X days.

Does anyone know a powershell command that can be run on Exchange 2010 SP1 that will permanently delete mail in the deleted items folder older than X days for ALL users in a specific database? This should include any user created subfolders in deleted items
also.
I know that seems bizarre to have user created subfolders in deleted items but we have found that users have discovered that if they create subfolders then their deleted items dont get purged at the regular retention period time.
Thank You.

Hi,
For Exchange 2010 SP1, we can use search-mailbox and new-mailboxexportrequest to delete message in certain folder.
Understanding Exchange Search
http://technet.microsoft.com/en-us/library/bb232132.aspx
Xiu Zhang
TechNet Community Support

Similar Messages

  • TS2481 All of my calendar history older than 30 days has disappeared from my iphone5.  I have not synced it with my computer.  It just suddenly disappeared.  Is there any way to get it back?

    All of my calendar history older than 30 days has disappeared from my iphone 4S.  I did not perform a sync with my computer-it literally just disappeared!  Is there any way to get it back?

    Unfortunatly for me I did not, do you think there might be any other way? Maybe by accesing it directly through direct USB contact and not through iTunes?

  • Powershell and Outlook 2007, trying to delete messages in a folder older than date

    I was hoping to get a powershell script that would do the following
    1) Connect to outlook 2007
    2) Go to Mailbox folder (not an inbox subfolder) called 'Processes'
    3) Delete all email from that folder older than 3 days old
    I did some searching, I have found very useful things like how to empty a deleted items folder.  I can even display all messages in that folder using this script snippet.  But whenever I try to filter it down to email older than 3 days old, it blows up on me.  I was attempting to use a | Where-Object pipe to reduce it and there are thousands of messages in that folder.
    $outlook = New-Object -ComObject Outlook.Application
    $olFolderInbox=6
    $n = $outlook.GetNamespace("MAPI")
    $f = $n.GetDefaultFolder($olFolderInbox)
    $mailbox = $n.Folders.Item($f.Parent.Name)
    $folder = $Mailbox.Folders.Item("Processes")
    $folder.Items
    #Clean out any open connections
    $outlook = $n = $f = $mailbox = $folder = $null;

    I thought I might offer another solution for this.  I came across this post looking to do the same, but I found it didn't always delete messages.  Based on some other information on another site I was able to come up with a modified version.
    The two other sites I referenced were:
    http://gallery.technet.microsoft.com/ScriptCenter/en-us/966637b9-0b70-41c0-99d0-4647a89da70a
    http://msdn.microsoft.com/en-us/library/bb220369%28office.12%29.aspx
    ----Script----
    #Name of folder to access.  You can specify subfolders by using FolderName\Subfolder
    $folderPath = "FolderName"
    #Filter older than 7 days
    $olderThan = (get-date).AddDays(-7)
    #Set format of date to use
    $dateFormat = "g" # This will base on time to do just date choose "M/dd/yyyy"
    #Create filter
    $sFilter = "[LastModificationTime] < `'$($olderThan.tostring($dateFormat))`'"
    $outlook = New-Object -ComObject Outlook.Application
    $olFolderInbox=6
    $n = $outlook.GetNamespace("MAPI")
    $f = $n.GetDefaultFolder($olFolderInbox)
    $mailbox = $n.Folders.Item($f.Parent.Name)
    $folders = $mailbox.Folders
    #Navigate to the proper folder
    foreach ($folderName in $folderPath.split("\"))
      $folder = $folders.Item($folderName)
      $folders = $folder.Folders
    $Items=$folder.items
    $FilteredItems = $Items.Restrict($sFilter)
    for ($i = $FilteredItems.Count; $i -gt 0; $i--) {
        Write-Host "Deleting $($FilteredItems.Item($i).Subject)"
        $FilteredItems.Item($i).Delete()
    #Clean out any open connections
    $outlook = $n = $f = $mailbox = $folder = $folders = $Items = $FilteredItems = $null;

  • TS4002 Messages older than 30 days in inbox are not moved to deleted items when removed.

    I've had a few messages that were stored in my inbox and were older than 30 days. I've noticed that when I actually delete them they aren't moved to Deleted Items (and sat for 30 days before permanently deleted). It seems that the actual date of the email is being used to calculate the age and not the time it sits in deleted items.

    If deleted email isn't being moved to the trash you might want to go to icloud.com from your computer, open mail, click on the gear-shaped icon on the top right and choose preferences, then confirm on the General tab that you have checked "Move deleted messages to" and selected "Tash" from the drop-down list.

  • How to delete Folders and Files older than 10 day ?

    If I use this below command, I am able to delete only the files and files in sub-folders older than 10 day,
    forfiles /p "D:\Testing\Sample" /s /d -10 /c "cmd /c del /s /q @file"
    Please help...
    Thanks

    Hello Raman459,
    please see this blog entry:
    http://elderec.org/2012/02/scripting-delete-files-and-folders-older-than-x-days/
    Your command is ok for files, for folders you need to do another command:
     forfiles -p "D:\Testing\Sample" -d -10 -c "cmd /c IF @isdir == TRUE rd /S /Q @path"
    If this post solved your question, please mark as an answer, or if it helped your quest, please vote as helpful. Thank you.
    Thank you,
    F. Schubert
    System Administrator
    MCP | Microsoft Certified Professional
    MCTS 70-640 | Microsoft Certified Technology Specialist: Windows Server 2008 Active Directory, Configuration
    MCTS 70-642 | Microsoft Certified Technology Specialist: Windows Server 2008 Network Infrastructure, Configuration
    MCTS 70-643 | Microsoft Certified Technology Specialist: Windows Server 2008 Applications Infrastructure, Configuring
    MCTS 70-680 | Microsoft Certified Technology Specialist: Windows 7, Configuration

  • "A script that will delete perfstat snapshots older than 90 days with SPPURGE..."

    Hello to all my fine Oracle related friends...We are all one large extended Family...
    I want to create a script that will execute SPPURGE on Perfstat for snapshots that are older than 90 days.
    Now, I have Grid 12c Cloud Control up and running for all the Databases that we have...
    Should I use Grid 12c to execute the SPPURGE and just pass the parameters in like that?
    Or should I go "Old School" and make a Shell Script and schedule it in the crontab?
    What would you guys do?
    I want implement this for 41 "Standard Edition" Databases....some are "Data Guard".....
    Thanks,
    Xevv.

    Xevv Bellringer wrote:
    Hi Ed,
    I tried executing this manually and it's not deleting the snapshots at all.
    begin
    statspack.purge(trunc(sysdate-90),true);
    end;
    I even let it for an entire day and then altered the code like this...But when I execute it, it doesn't deleted the data..
    begin
    statspack.purge(trunc(sysdate-1),true);
    end;
    When I do a select sysdate -1 from dual; it gives the correct date?
    Could there be a "NLS Setting" some where causing this?
    How do you determine that it is not deleteding data?  (please show evidence)
    How, and how often, are you collecting a statspack snapshot?  (please show evidence)

  • ICM 7.5.9 deletes DD records older than 15 days

    Hi guys,
    I have a strange thing happening with our ICM 7.5.9 installation...
    The Dialer Detail table for the Outbound Option deletes the records older than 15 days...
    I checked the purge jobs and they all reference registry keys which have a value of 1000 + days...
    This only happens with the DD table... all the other historical tables retain the data as set in the reg keys...
    I have no clue where to start troubleshooting this... anyhelp is wellcome.

    Below is the link to check the logs if the purge cycle on HDS was successful.
    http://www.cisco.com/en/US/products/sw/custcosw/ps1001/products_qanda_item09186a008020f1e2.shtmlSo turn on the EMSTraceMask to ffff for rpl process on the AW and check the logs around mid night it should give you some clue.
    Use the ICMDBA to check the size of your hds db if it is 80%+ full it will start purging
    the tables.
    eg trace would look like,
    09:52:39 dis-rpl Trace: 80% of the available free space is used in
    XX_hds database.
    09:56:39 dis-rpl Trace: 80% of the available free space is used in
    XX_hds database.
    If you see similar messages expand the HDS db using the below link
    http://www.cisco.com/en/US/products/sw/custcosw/ps1001/products_tech_note09186a0080094927.shtml
    Hope this helps.
    Shirish

  • Dates in email all the same when older than 2 days. I saw similare questions but no solutions , who can help me ?

    All dates in my emails (on all my 4 apple computers) are on May 5 , when older than 2 days. Is there anyone who can help me out of this very annoying problem please?
    I saw simmilar questions from people in 2008  but no answers.
    Thanks in advance.

    solved

  • How could I delete files with name string with "TAL" and older than 05.05.

    How could I delete files with name string with "TAL" and older than 05.05.2009 on unix

    Our ECC Ides system today was not responsible. For first time 17 users were working on the systtem (IWN2008/SQL2005 based). Before the people were maximally 5.
    The server is done by making a homogeneous system copy from an blade machine(now it is an VIrTUAL)
    There was enaught disk space. However I checked Wokload 03sdn transaction) inn system. and found out that at that time of restarting(I had to restart system 3 times to get logged on the system and even then it was almost unresponsive.
    I can found in there top abap."Login_Pw", "SESSION_MANAGER", "?". (BAtch), "ADMSBUF, >DEleyed Function call, RSPOWPOO""RSWWclear", ""VA01", "SAPMHHTP  "Buf  Sync" >DDLOC CLEANUP)""rsbtctE"
    What can I do?
    ¸
    Who could interfer SAP_CCMS_MONI_BATCH_DPSAP_CCMS_MONI_BATCH_DP
    the 2 main users under users profile were ZUGTIN running and SAPSYS( running many system jobs)
    How to approach the problem

  • Will the backup metadata older than 10 days be deleted automatically?

    If the CONTROL_FILE_RECORD_KEEP_TIME parameter is set to 10, will the backup metadata older than 10 days be deleted automatically?----No.151

    http://download-east.oracle.com/docs/cd/B19306_01/backup.102/b14191/rcmarchi003.htm#sthref58

  • Would like to automate this Powershell command that sets the UPN of all mail enabled users

    I have command that changes the UPN of all mailbox users
    Get-ADUser -Filter * -properties homemdb | where {$_.homemdb -ne $null} | ForEach-Object ($_.SamAccountName) {$CompleteUPN = $_.SamAccountName + “@contoso.com”; Set-ADUser -Identity $_.DistinguishedName -UserPrincipalName $CompleteUPN}
    The command works using the AD module for
    powershell. What I would like to do it write a script that does the following.
    Runs the command above
    Only applies changes to users that need it. (I think this applies the setting to all users with the "homemdb")
    I was thinking of setting it as a scheduled task on one of the Domain Controllers. My
    powershell skills are lacking at best, so any guidance on how to set this up would be much appreciated. 
    Thanks

    Cannot bind parameter 'Filter' to the target.
    Exception setting "Filter":
    "Invalid filter syntax. For a description of
    the filter parameter syntax see the command help.
    "(RecipientType -eq
    'UserMailbox') -and
    (UserPrincipalName -notlike
    ('*@{1}' -f $UPNSuffix))" at position 68."
        + CategoryInfo         
    : WriteError:
    (:) [Get-User],
    ParameterBindingException
        + FullyQualifiedErrorId
    : ParameterBindingFailed,Microsoft.Exchange.Management.RecipientTasks.GetUser
    Read the error very carefully: "Invalid filter syntax"
    You filter: "(RecipientType -eq
    'UserMailbox') -and
    (UserPrincipalName -notlike
    ('*@{1}' -f $UPNSuffix))"
    This is not a good filter for anything.
    This is not legal in a filter: (UserPrincipalName
    -notlike ('*@{1}'
    -f $UPNSuffix))"
    See filter syntax for rules on the limited support for PowerShell syntax.   filters are a subset.
    ¯\_(ツ)_/¯

  • Delete content of all users Download folders

    Hi ,
    I checked in the forum for that but did not find anything that can suits my issue.
    I need to delete all the content of all users download folder every night .
    I tried this
    %userprofile%\Downloads | where {($_.LastWriteTime).AddDays(1) -lt (get-date)} | remove-item -force -recurse
    but  it does not help.
    Could you please help me or put me in the right direction .
    Thanks
    AGYL

    Hi ,
    I checked in the forum for that but did not find anything that can suits my issue.
    I need to delete all the content of all users download folder every night .
    I tried this
    %userprofile%\Downloads | where {($_.LastWriteTime).AddDays(1) -lt (get-date)} | remove-item -force -recurse
    but  it does not help.
    Could you please help me or put me in the right direction .
    Thanks
    AGYL
    You are using what looks like PowerShell mixed with batch.  % variables do not exeisits in PowerShell they are in the form of $env:USERPROFILE.  That variable is only valid for the currently logged in users.  It is not global.
    Normally we would do this with Group Policy and not with a script.  Yu can do it with a GP scheduled task or on every login.  Contact you Administrator to set this up for you.  If you decide to do this centrally then you will also need your
    network Admin to help you.  You will need to design a method that fits your network.
    If you do not have an Admin trained in Windows Networking then you can try and contact a consultant or you can take time to study the learning materials until you understand how Windows and scripting work.  The links on the top of this page are a good
    place to start.
    ¯\_(ツ)_/¯

  • Everyone Deny Delete ACL on all user preferences

    Hi, I know that user accounts have an ACL on certain folders to prevent them being deleted, but on one of my users this ACL has appeared on all his preferences files and folder, and they are all explicit so I can't just change the enclosing folder and propagate to remove them.
    does anyone know a terminal command I could use to remove all of these because at the moment if the user tries to change any application preferences the app will crash on quit.

    This has happened to 50+ accounts on my file server as well, on accounts that were created only 2 weeks prior. I'd like to find out why this happens and how to prevent it.
    I find myself having to hand edit perms, which is a huge pain.

  • How to get all kind of GP work items for all users

    Dear all:
       Basing GP implementation,we can only get the single user's work item. Is that possible to get all of the users' work items,and can filter the work item via time field?
      thanks a lot.

    ISearchResult result=UMFactory.getUserFactory().getUniqueIDs();
                   IUser iuser;
                   while(result.hasNext())
                        iuser=UMFactory.getUserFactory().getUser(result.next().toString());
    The above code retrives all the users from the UME
    IGPUserContext context = GPContextFactory.getContextManager().createUserContext(iuser);
    IGPWorkItem[] workitems = GPProcessFactory.getRuntimeManager().getWorkItems(GPWorkItemStatus.getTypeForCode("1"), context);
    You will get the WorkListItems in the workitems array. The type for code which is 1 currently, must be changed according to the requirement. It is different for Completed, Inprogress Tasks, etc.
    Hope this will help you!

  • How to copy billing plan details of main item to all its sub-items...

    In the sales order, we have main item and sub-items. The main item is a project item and it has a billing plan which gets copied from the project. Now the requirement is to copy the same billing plan(of the mainitem) to all its subitems- billing dates, billing type, billing rule, date category, percentage of the amount to be billed, etc. So that when we do billing for this sales order all the items and its sub items are copied in the milestone billing document.
    The billing plan is not at header level since the sales order can have multiple project items and their milestones can differ.
    Please suggest how to acheive this- coping of billing plan details from main item to all the subitems.
    Rds,
    sucmsss

    You can use the enhancement section in include mv45af0f_fplan_aktualisieren_c. In the below code, I am copying milestone lines from previous document, but you could adapt to copy from the higher level item. Copy and pretty print it in ABAP editor.
    ENHANCEMENT 10  ZSD_SALES_DOC1.    "active version * Generate Billing Plan without dialog. * Because copy control does not work with milestone billing plans, we need to perform the below tricks.
      DATA: zlt_fplt TYPE TABLE OF fpltvb,         zlt_fpla TYPE TABLE OF fplavb,         zlv_fareg TYPE tfpla-fareg,         zlv_fplnr TYPE fplnr,         zls_vbkd TYPE vbkd.   FIELD-SYMBOLS:TYPE vbkdvb,                 TYPE fplavb,                 TYPE fpltvb,                 TYPE fpltvb.
    IF xvbkd-updkz = chari AND       tvap-fpart IS NOT INITIAL AND *      xfplt[] IS INITIAL AND       vbkd-fplnr IS INITIAL AND "bill plan not created       vbak-vbtyp CA 'CG'. "contracts and orders       SELECT SINGLE fareg FROM tfpla INTO zlv_fareg WHERE         fpart = tvap-fpart.         IF zlv_fareg IS NOT INITIAL AND           zlv_fareg <> '6'.         READ TABLE cvbkd ASSIGNINGWITH KEY         vbeln = vbap-vgbel         posnr = vbap-vgpos.         IF sy-subrc IS INITIAL.           CALL FUNCTION 'BILLING_SCHEDULE_READ'             EXPORTING              fplnr          =-fplnr             tables              ZFPLA          = zlt_fpla              zfplt          = zlt_fplt. * Check if any of the lines are not periodic and not from milestone before proceeding.            READ TABLE zlt_fplt ASSIGNINGWITH KEY            MLSTN = abap_false            nfdat = 0.          IF sy-subrc IS INITIAL.           CONCATENATE '$000' vbap-posnr INTO zlv_fplnr.           ENDIF.         ENDIF.         IF sy-subrc IS INITIAL.           LOOP AT zlt_fplt ASSIGNINGWHERE             mlstn = abap_false.            -fplnr = zlv_fplnr.             APPENDTO xfplt.            -updkz = chari.           ENDLOOP.           LOOP AT zlt_fpla ASSIGNING.            -fplnr = zlv_fplnr.             CLEAR-vbeln.            -updkz = chari.             APPENDTO xfpla.           ENDLOOP.           da_fplnr =-fplnr.         ENDIF.       ENDIF.     ENDIF.     CALL FUNCTION 'BILLING_SCHEDULE_GENERATE'          EXPORTING               I_FKDAT        = VBKD-FKDAT               I_FPLNR        = DA_FPLNR               I_WAERS        = VBAK-WAERK               I_FPART        = TVAP-FPART               I_VEDA         = XVEDA               I_VEDA_KOPF    = VEDAVB               I_UPD_FPLA     = UPD_FPLA               I_UPD_FPLT     = UPD_FPLT               I_KOMK         = TKOMK               I_KOMP         = TKOMP               I_KOMPAX       = KOMPAX               I_FKREL        = VBAP-FKREL               I_CREATE_DATES = US_FLG_CREATE_DATES               I_KFPLAN       = DA_KFPLAN               I_KFPLNR       = DA_KFPLNR               I_NOMSG        = US_NOMSG               I_ABSAGEN      = DA_ABSAGEN               I_FPLAA        = FPLAA          IMPORTING               E_FPLNR        = XVBKD-FPLNR               E_DATALOSS     = DA_DATALOSS               E_UPD_FPLA     = UPD_FPLA               E_UPD_FPLT     = UPD_FPLT               E_KOMPAX       = KOMPAX          TABLES               FPLA_NEW       = XFPLA               FPLA_OLD       = YFPLA               FPLT_NEW       = XFPLT               FPLT_OLD       = YFPLT               I_FPLTS        = TFPLTS               I_FPLTNP       = TFPLTNP               I_KOMV         = XKOMV               I_TKOMK        = TKOMK               I_SVBAP        = UVBAP.     LOOP AT zlt_fplt ASSIGNING.       READ TABLE xfplt ASSIGNINGWITH KEY       mandt =-mandt       fplnr =-fplnr       fpltr =-fpltr.       CHECK sy-subrc IS INITIAL.      -updkz = chari.     ENDLOOP. ENDENHANCEMENT.

Maybe you are looking for

  • Problem with dvd capture Prem Elem 10 Trial version

    When I capture video from a dvd, it only captures some files, not all using the Trial version. 40% of video did not capture. Why does this happem?

  • Bad support for ts hint in Oracle jdbc driver (for preparedStatement)

    hi I have the following SQL SELECT TRUNC({ ts '2004-01-01 00:00:00.0' }) FROM ET1_ELEMENT With the jdbc.odbc driver the following meta data is returned: ResultSet meta data are... Column [1] name [TRUNC(TO_DATE('2004-01-0100:00] type [93] class name

  • Date Format in text

    Hai all I want to get the date format in text like dd/mm/yyyy based on the locale value. Is it posible to get the string format insted of date. Thanks a lot Aniesh U.K

  • Photoshop CS_6 Mac Stopped Working

    Suddenly Photoshop CS_6 for Mac has stopped working. Not a trial copy but licensed. When I uninstall and reinstall I get a Configuration error 16.

  • ITunes do not detect / recognize iPod Touch 64 GB

    Hello Everyone, I am Aaron from South India. Recently, I bought my first Apple product - brand new iPod Touch 64 GB. I connected it to the Computer (Windows XP with iTunes 2009) in our Church. The iPod connected to the system without any issues, allo