Jessica Cochran
asked on
Delete all Messages 6 months and older - Exchange 2010
Hi
I am looking for a working Powershell cmd to delete the messages in the following folders:
Inbox, Sent Items and Deleted Items that are older than 6 months old for my users on a certain database server
I have tried a handful of commands and nothing seems to be working, feel like I am missing something.
I am looking for a working Powershell cmd to delete the messages in the following folders:
Inbox, Sent Items and Deleted Items that are older than 6 months old for my users on a certain database server
I have tried a handful of commands and nothing seems to be working, feel like I am missing something.
ASKER
I don't want to search for a certain subject I literally need to delete all contents in those folders older than 6 months but I do not want to touch the folders underneath the inbox.
Plus I need to delete them not put them in a different acct.
Does that make sense?
Plus I need to delete them not put them in a different acct.
Does that make sense?
Read this Page - https://technet.microsoft.com/en-us/library/dd298173(v=exchg.150).aspx
you need the Search-Mailbox cmdlet for it to work and also date parameters. You can leave the "From" out but I suggest you use LogLevel Full. Read what each of these do and decide what you need. Also highly recommend that you have a current backup of your server.
Also note that "target folder" is not the same as "folder" where the former is where the report is sent and the latter is what folder you want the content deleted.
https://technet.microsoft.com/en-us/library/ff459253(v=exchg.150).aspx#Anchor_3
The Search-Mailbox cmdlet to search a mailbox and copy the results to a specified target mailbox, delete messages from the source mailbox, or both.
you need the Search-Mailbox cmdlet for it to work and also date parameters. You can leave the "From" out but I suggest you use LogLevel Full. Read what each of these do and decide what you need. Also highly recommend that you have a current backup of your server.
Also note that "target folder" is not the same as "folder" where the former is where the report is sent and the latter is what folder you want the content deleted.
https://technet.microsoft.com/en-us/library/ff459253(v=exchg.150).aspx#Anchor_3
This link explains better what you can and can't do. I was wrong about the folder option. You can't delete from a specific folder but what you can d is search a mailbox and get specific information on subjects, senders and times and move or delete that way.
https://www.petri.com/delete-email-from-microsoft-exchange-user-mailboxes-using-powershell
https://www.petri.com/delete-email-from-microsoft-exchange-user-mailboxes-using-powershell
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi Jessie,
The Search-Mailbox -DeleteContent cmdlet is a good bet, but it doesn't let you search specific folders. Would deleting all email-type items be ok?
For more see this article: https://www.codetwo.com/admins-blog/how-to-delete-email-from-mailboxes-on-exchange-2016-2013-2010-online/?sts=6650
If not, retention tags are the way to go.
Best regards,
CodeTwo
The Search-Mailbox -DeleteContent cmdlet is a good bet, but it doesn't let you search specific folders. Would deleting all email-type items be ok?
Get-Mailbox -ResultSize unlimited | Search-Mailbox -SearchQuery 'kind:email AND received<#Date in MM/dd/yyyy format#' -DeleteContent
For more see this article: https://www.codetwo.com/admins-blog/how-to-delete-email-from-mailboxes-on-exchange-2016-2013-2010-online/?sts=6650
If not, retention tags are the way to go.
Best regards,
CodeTwo
ASKER
I am trying a Retention Policy now on one of the accounts to see if it will work. Does anyone know if it is possible to find out if a policy has run on an acct?
ASKER
I used a Retention Policy and it seems to do what I need it to do.
See:
For Exchange 2010 - https://technet.microsoft.com/en-us/library/ff459253(v=exchg.141).aspx
For Exchange 2013 - https://technet.microsoft.com/en-us/library/ff459253(v=exchg.150).aspx