PowerShell: Search public folders for items of a particular message class (ItemClass)

In addition to the mailbox search script, I have also written a sample script showing how to do the same search against public folders.  It works in exactly the same way, but iterates public folder tree instead of the mailbox.

The EWS Managed API needs to be installed on the machine running the script, but it does not need to be run on an Exchange server.  Example syntax:

.\Search-PublicFoldersForMessageClass <mailbox smtp address> <message class>

Full list of parameters:

  -Mailbox: Specifies the mailbox to be used to obtain autodiscover information
 -MessageClass: Specifies the message class of the items being searched
 -AuthUsername: Username used to authenticate with EWS (if omitted, the logged in user's credentials are used)
 -AuthPassword: Password used to authenticate with EWS
 -AuthDomain: Domain used to authenticate with EWS
 -Impersonate: Whether we are using impersonation to access the mailbox (defaults to false)
 -EwsUrl: EWS Url (if omitted, then autodiscover is used)
 -EWSManagedApiPath: Path to managed API (if omitted, a search of standard paths is performed)
 -IgnoreSSLCertificate: Whether to ignore any SSL errors (defaults to false)
 -LogFile: Log file - activity is logged to this file if specified (if omitted, it is just written to console)


Comments (2)

  1. Edo says:

    Is it possible for this script to be directed at a specific subfolder of PublicFoldersRoot?  I need to search for Enterprise Vault links but only in a specific subset of Public Folders. The exchange environment I am working with has 1000's of legacy public folders so if the search starts at  the Public Folder Root it could literally take days for this script to complete.  Thanks for any assistance you can offer.  

  2. Mario says:


    is this script usable with Exchange 2007 SP1? I tried, but I get an error in this line:

    $results = $service.FindItems( $FolderId, $searchFilter, $view )

    Error: Cannot find an overload for "FindItems" and the argument count: "3"

    Without SearchFilter it is running, but there is no result. I think in this case there must be all items in the result (that is by the way what I need, I need all items without a filter).

    How is it possible to adapt it for Exchange 2007?



Skip to main content