Skip to content
David Barrett edited this page Nov 14, 2023 · 14 revisions

PowerShell EWS Scripts

This is a collection of PowerShell scripts that can perform a variety of mailbox related tasks using Exchange Web Services. EWS is available in both Exchange Online (until October 1, 2026) and on-premises. Most scripts will work in either environment.

Basic tasks can be achieved more easily using Graph; take a look at the Microsoft Graph PowerShell SDK, or experiment with Graph Explorer.

All scripts are provided as samples only. It is up to the user to validate that they work, and to take any necessary precautions before running (e.g. backing up a mailbox). Some of the scripts are potentially highly destructive (depending upon the parameters passed in).

To use the scripts with Exchange Online, you must use OAuth. Please see this guide for the initial configuration steps. There is also a guide for Exchange On-premises.

This script can be used to create lists of mailboxes, each list containing a specific number of mailboxes.

This script can be used to restore deleted items (from Deleted Items folder or Recoverable Items). There are various options for restoration including restore to last known folder and/or to default folders based on item type.

This script can be used to search and delete duplicate items, per folder or throughout the whole mailbox depending upon parameters.

This script can be used to search and export calendar items based on various filters. It can also be used to delete calendar items.

This script can be used to search and export any items based on various filters.

This script can be used to bulk move/copy items between folders. It can also be used to move items to and from the archive mailbox, and in some cases between mailboxes (this depends on access permissions and also the locations of the mailboxes - it can't transfer between tenants, for example).

This script can be used to bulk update items in a mailbox, including custom (MAPI) properties. It can filter on custom MAPI properties also. There is additional functionality such as item resend and meeting invitation processing.

This script can be used to bulk update folders in a mailbox, including custom (MAPI) properties. It can filter on custom MAPI properties also.