Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Office 365 remove messages by date range for several users using powershell

Posted on 2014-11-13
2
2,540 Views
Last Modified: 2014-11-25
Hi,

I have an Office365 account, we have several mailboxes. We would like to delete message for several users by date range. Is there a way with powershell?

Deleting using Outlook or Outlook Web App will take too long.
0
Comment
Question by:NRTCF
2 Comments
 
LVL 9

Accepted Solution

by:
Veerappan Sundaram earned 500 total points
ID: 40441906
Before you do this, please check the legal requirements of your organization on "Email retention"

Do you have access to O365 Online Administration Center? Do you have required permission to run Exchange cmdlets?

If yes, you need to use the Remote Windows Powershell to run Search-Mailbox cmdlet to delete content.

please refer this link: http://technet.microsoft.com/en-us/library/exchange-online-administration-and-management.aspx 

search-mailbox -identity "user_ID" -searchquery {sent:01/01/2010..01/01/2012} -TargetMailbox "different_Mbx_name" -targetfolder "folder_name" -logonly   (Run this to confirm you get the expected result before deleting)

Search-Mailbox -identity "User_ID" -searchquery {sent:01/01/2010..01/01/2012} -Deletecontent

Thanks,
Veera.
0
 
LVL 5

Expert Comment

by:Mai Ali (MVP)
ID: 40450328
you can remove emails for one user by using the Search-Mailbox cmdlet with the DeleteContent parameter to search for and delete messages in one step
For delete message for several users by date range, You can use Search For and Delete Messages from Users' Mailboxes
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you irritated by repeating emails issue in Microsoft Outlook 2016 after recent update ?  Lets’ see how to resolve and prevent duplicate emails in the Outlook 2016 using some simple techniques.
This article explains how to install and use the NTBackup utility that comes with Windows Server.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question