About: Using EWS and PowerShell

Exchange PowerShell cmdlets are used for Administrative work on a server and with mailboxes.  However, it provides very little access to things inside the mailbox.  Exchange PowerShell is geared to Admin work and not working with things inside of a mailbox. To work with items in a mailbox you need another mail – the type made for mailbox access.  You can use Exchange Web Services (EWS) against all versions of Exchange from 2007 to the latest. Most samples for using EWS are either ones with C# or raw EWS SOAP calls.  However, there is a lot of samples and information on using it with PowerShell because it's often used by Administrators and developers.

I've included information on using the EWS Managed API with PowerShell.  The training series is from a Microsoft MVP and should be well worth reading.  In addition, I'm including information covering scenarios we commonly see issues with customer code.

Beginning information:

Below is general information on the EWS Managed API.

EWS Managed API
https://github.com/OfficeDev/ews-managed-api
The EWS Managed API is open-sourced and Microsoft publishes it on GitHub. It's best to download it and build in order to get the latest fixes.

Microsoft Exchange Web Services Managed API 2.2
https://www.microsoft.com/en-us/download/details.aspx?id=42951
This is Microsoft's download link.

Start using web services in Exchange
/en-us/exchange/client-developer/exchange-web-services/start-using-web-services-in-exchange

Develop web service clients for Exchange
/en-us/exchange/client-developer/exchange-web-services/develop-web-service-clients-for-exchange
This has links to the type of operations to be done.

Best Practices: EWS Managed API coding for Exchange
https://blogs.msdn.microsoft.com/webdav_101/2016/04/12/ews-managed-api-coding-for-exchange

About: Exchange Web Services (EWS) – Getting started with EWS
https://blogs.msdn.microsoft.com/webdav_101/2015/05/03/getting-started-with-ews/

Accessing many mailboxes:

To access more than one mailbox you will either need to use EWS Impersonation or Delegate access.  Normally EWS Impersonation is used to access many mailboxes.  However, Delegate access can also be used.  EWS Impersonation has a lot of advantages over delegate access and is far less likely to get throttled.

Authentication and EWS in Exchange
https://msdn.microsoft.com/en-us/library/office/dn626019(v=exchg.150).aspx

Impersonation and EWS in Exchange
https://msdn.microsoft.com/en-us/library/office/dn722377(v=exchg.150).aspx
With Impersonation a service account has full access to a defined set of mailboxes. What it can access in those mailboxes (such as specific folders) cannot be filtered or defined.  Only an Exchange Admin can configure an EWS Impersonation account for impersonating and configure its mailboxes to allow the impersonation.

Delegate access and EWS in Exchange
https://msdn.microsoft.com/en-us/library/office/dn641957(v=exchg.150).aspx
Delegate access allows a user to access certain folders in another user's mailbox  Delegate permissions can be set by a mailbox owner or administrator using an app or other app code.

Training series on EWS and PowerShell:

Below is a training series by Glen Scales.

EWS Managed API and Powershell How-To series Part 1
https://gsexdev.blogspot.com/2012/01/ews-managed-api-and-powershell-how-to.html

EWS Managed API and Powershell How-To series Part 2 - Folders
https://gsexdev.blogspot.com/2012/01/ews-managed-api-and-powershell-how-to_23.html

EWS Managed API and Powershell How-To series Part 3 - Items                                                                                           
https://gsexdev.blogspot.com/2012/02/ews-managed-api-and-powershell-how-to.html

EWS Managed API and Powershell How-To series Part 4 - Items Part 2
https://gsexdev.blogspot.com/2012/02/ews-managed-api-and-powershell-how-to_22.html

EWS Managed API and Powershell How-To Series Part 5 Delegate Operations
https://gsexdev.blogspot.com/2012/03/ews-managed-api-and-powershell-how-to.html

EWS Managed API and Powershell How-To Series Part 6 FreeBusy and OOF Operations
https://gsexdev.blogspot.com/2012/03/ews-managed-api-and-powershell-how-to_27.html

EWS Managed API and Powershell How-To Series Part 7 Using the Configuration Information Operation
https://gsexdev.blogspot.com/2012/04/ews-managed-api-and-powershell-how-to.html

EWS Managed API and Powershell How-To Series Part 8 Folder Permissions
https://gsexdev.blogspot.com/2012/05/ews-managed-api-and-powershell-how-to.html

EWS Managed API and Powershell How-To Series Part 9 EWS Notifications
https://gsexdev.blogspot.com/2012/05/ews-managed-api-and-powershell-how-to_28.html

EWS Managed API and Powershell How-To Series Part 10 Message Classifications  
https://gsexdev.blogspot.com/2012/06/ews-managed-api-and-powershell-how-to.html

EWS Managed API and Powershell How-To Series Part 11 Moderation
https://gsexdev.blogspot.com/2012/07/ews-managed-api-and-powershell-how-to.html

Note that the blog site for the above articles lot of samples where PowerShell and EWS are used. Many of these samples are very helpful for admins.

Note about headers:

There are headers which should be set and in many cases they must be set on an EWS call. Be sure to implement them in your code.

Best Practices: Important and critical headers for EWS
https://blogs.msdn.microsoft.com/webdav_101/2018/06/16/best-practices-important-and-critical-headers-for-ews

EWS Schema version:

The EWS Schema Version is often a point of confusion – this article discusses how it should be set:

EWS Schema Versions – Why can't I pick versions for 2007 SP2/SP3 or 2010 SP3?
https://blogs.msdn.microsoft.com/webdav_101/2014/12/04/ews-schema-versions-why-cant-i-pick-versions-for-2007-sp2sp3-or-2010-sp3/

Read about throttling:

It's important that you consider possible Exchange Throttling when designing your application and writing code.

Exchange throttling is your friend… well, more like a police officer.
https://blogs.msdn.microsoft.com/webdav_101/2015/11/18/exchange-throttling-is-your-friend-well-more-like-a-police-officer

Best Practices – EWS Throttling
https://blogs.msdn.microsoft.com/webdav_101/2015/05/03/best-practices-ews-throttling

EWS ServerBusyException – The server is too busy – for you
https://blogs.msdn.microsoft.com/webdav_101/2018/03/20/ews-serverbusyexception-the-server-is-too-busy-for-you/

You are doing too much at one time: EWSMaxConcurrency – "too many concurrent connections opened"
https://blogs.msdn.microsoft.com/webdav_101/2018/06/02/you-are-doing-too-much-at-one-time-ewsmaxconcurrency-too-many-concurrent-connections-opened

Also:

Here are some additional articles to go over:

Best Practices: EWS Managed API coding for Exchange
https://blogs.msdn.microsoft.com/webdav_101/2016/04/12/ews-managed-api-coding-for-exchange

EWS Best Practices
https://blogs.msdn.microsoft.com/webdav_101/2015/05/03/ews-best-practices/

Best Practices – EWS Authentication and Access Issues
https://blogs.msdn.microsoft.com/webdav_101/2015/05/11/best-practices-ews-authentication-and-access-issues
This article covers many of the gotcha's which you may encounter with EWS.

Exchange samples: learn through code
https://code.msdn.microsoft.com/exchange
There are a lot of samples at this site.

Exchange 2013 101 Code Sample
https://code.msdn.microsoft.com/exchange/Exchange-2013-101-Code-3c38582c
It's a zip file filled with samples for a lot of EWS calls.