Book Image

Microsoft Exchange Server Powershell Cookbook (Update)

Book Image

Microsoft Exchange Server Powershell Cookbook (Update)

Overview of this book

Table of Contents (21 chapters)
Microsoft Exchange Server PowerShell Cookbook Third Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Using a date range search


The following table outlines the properties that can be used to define an AQS query using a date range restriction:

Property

Example

Description

Received

Received:today

This searches for items received today

Received:05/15/2015

This searches for items received on May 15

Received:05/01/2015..05/30/2015

This searches for items received between May 1 and May 30

Sent

Sent:today

This searches for items sent today

Sent:05/15/2015

This searches for items sent on May 15

You can use relative dates when performing a date range restricted search. For example, today, tomorrow, or yesterday can be used with the Received or Sent keywords.

You can use a specific day of the week: (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, or Saturday) with the Received or Sent keywords.

You can also use a specific month: (January, February, March, April, May, June, July, August, September, October, November, or December) with the Received or Sent keywords.

Examples

If you want to delete all messages in the administrator mailbox that were received today, use the following command:

Search-Mailbox -Identity administrator '
-SearchQuery "Received:today" '
-DeleteContent '
-Force

If you want to delete all messages in the administrator mailbox that have been received between March and July, use the following command:

Search-Mailbox -Identity administrator '
-SearchQuery "Received:03/01/2015..07/01/2015" '
-DeleteContent '
-Force