Automatically delete old existing emails in Office 365

I am having difficulty on finding out how to delete all emails older than 365 days on a specific mailbox.

Please note that the search-mailbox command below does not work on Office 365.
 
search-mailbox -identity <username> -SearchQuery "Received:<$('01/01/2014')" -deletecontent

Open in new window


Thanks for your help
LVL 1
the_omnificAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Naitik GamitSoftware DeveloperCommented:
this is happen bcoz of Mailbox Import Export role isn't assigned to any role group by default.

Login to ECP
Click “Roles & Auditing”
Double click on “Organization Management”
Add “Mailbox Import Export” role
Check your account is in the member list. If not add your account into the list
Wait for a while then try the cmdlet again


For Messaging Policy Refer Link:
https://technet.microsoft.com/en-us/library/dd638205.aspx
0
SreRajCommented:
Hi,

As per the following article, search-mailbox will work in Exchange Online. Please check the syntax. Also you would require eDiscovery Permissions to search and delete mailbox content. Second article has information regarding that.

https://technet.microsoft.com/en-us/library/dd298173(v=exchg.150).aspx

https://technet.microsoft.com/en-us/library/dd298059(v=exchg.150).aspx
0
the_omnificAuthor Commented:
Naitik Gamit, there is no roles and auditing. And Mailbox Import Export is not apart of Office 365 (Exchange Online 2013)
 
SreRaj

PS C:\Windows\system32> search-mailbox -identity alan -SearchQuery "Received:<$('01/01/2014')" -deletecontent
search-mailbox : The term 'search-mailbox' is not recognized as the name of a
cmdlet, function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ search-mailbox -identity alan -SearchQuery "Received:<$('01/01/2014')"
-deleteco ...
+ ~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (search-mailbox:String) [], Comm
   andNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
 
PS C:\Windows\system32>

Open in new window

0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

the_omnificAuthor Commented:
The admin user running the command is a member of Discovery Management role
0
Alexa JacksonDigital Forensic AnalystCommented:
Hi,

As per the information and details provided by you, to automatically delete an email older than 365 days in office 365, please follow these steps:-

If you want to delete all email older than 365 days, you can create a policy to the folder in Outlook client.

•      Right click “that folder” > Properties > Policy > select Delete after 1 year (1 year).

Note: - if there is no Deleted after 1 year option, it means the retention policy assigned to you does not contain the retention tag. In this situation, if you are, the Office 365 admin, I suggest you create a new retention policy in Exchange Admin Center (“compliance management” – “ retention tags” & “retention policies”) and assign it to you via the following steps: -

•      Create a 1 year delete tag.
•      Create a retention policy and add the tag into it or add the tag in an existed policy.
•      Assign the retention policy to the dedicated user.

If not, please ask your Office 365 admin for help.

Thanks and regards
Alexa@J
0
the_omnificAuthor Commented:
I thought about retention policies and called Microsoft and retention policies only appy to emails from the day the retention policy is created. Not existing emails.
0
SreRajCommented:
You will have to establish a remote session to office 365 from the PowerShell Console. Please try following article.

https://technet.microsoft.com/en-us/library/jj984289(v=exchg.150).aspx
0
the_omnificAuthor Commented:
I am already remotely connected to Office 365 via remote powershell. I am able to run other commands on that environment
0
SreRajCommented:
This could be the problem with eDiscovery Permission then. Please try executing the command and see if the account you are using is present as Member.

Get-RoleGroupMember -Identity "Discovery Management"

Also, please connect to Office 365 Exchange Admin Center and try to do a search from

Recipients -> Compliance Management -> In-Place eDiscovery & Hold
0
ycdcnCommented:
You could create a rule to delete email over a certain age.
0
the_omnificAuthor Commented:
SreRaj running that command displays the correct members of the group.
0
the_omnificAuthor Commented:
I rule would only apply to new incoming and outgoing?
0
ycdcnCommented:
you can create a rule to apply to emails before a particular date, select delete, you can select some exceptions if you like, and then tick the box to apply to emails currently in Inbox.
0
the_omnificAuthor Commented:
I know you can do this in Outlook but not in Exchange Management Console?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
the_omnificAuthor Commented:
I run a the rule in Microsoft Outlook. I couldn't find a way of doing it in O365
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Office 365

From novice to tech pro — start learning today.