User impersonation
As seen in the previous section, some activities can be executed only by the account being targeted. In the preceding example, not even a global administrator can create an inbox rule that uses text messaging (more on security on the next section). However, we have the option of user impersonation. At the time of writing this, user impersonation can be used only through EWS.
EWS pre-dates PowerShell and Office 365 and can be used for system integration and application development, hence its implementation of user impersonation. Fortunately, once we get familiar with the API, using EWS can be leveraged in our PowerShell scripts.
Installing Exchange Web Services
EWS can be downloaded from the Microsoft website (https://www.microsoft.com/en-us/download/details.aspx?id=42951); the project is open source and is available on GitHub (https://github.com/OfficeDev/ews-managed-api). The installation is straightforward and will copy the files to Program Files\Microsoft\Exchange\Web...