O'Reilly logo

Microsoft Exchange Server PowerShell Cookbook - Third Edition by Mike Pfeiffer, Jonas Andersson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Searching mailboxes

The EWS Managed API can be used to search one or more folders within an Exchange mailbox. The latest version of the API supports searches using Advanced Query Syntax, allowing us to search folders using the indexes created by the Exchange Search service. This makes searching a mailbox folder very fast and less resource-intensive than methods that were used with previous versions of the API. In this recipe, you'll learn how to search the contents of a mailbox through PowerShell and the EWS Managed API.

How to do it...

Let's see how to search the contents of a mailbox using the following steps:

  1. First, load the assembly, create the ExchangeService object, and connect to EWS:
    Add-Type -Path C:\EWS\Microsoft.Exchange.WebServices.dll ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required