Writing a basic script
As this book is about managing Exchange using PowerShell, let's use the PowerShell client to save a draft message in the administrator's mailbox. I have installed the EWS managed API 2.2 at C:\Program Files\Microsoft\Exchange\Web Services\2.2
, which is the default location. You can install it on any other location and ensure that the correct path is referenced.
In my lab, I am using Exchange 2013 Service Pack1, but the process is similar in Exchange 2016 and Exchange online. The only thing that you need to understand is how to target the correct Exchange version that is described next.
The first step is to import the Microsoft.Exchange.WebServices.dll
module in PowerShell using a variable:
$EWSDllPath = "C:\Program Files\Microsoft\Exchange\Web Services\2.2\Microsoft.Exchange.WebServices.dll" Import-Module $EWSDllPath
The next step is to create the service object just as we did in the earlier sections using C# code in Visual Studio:
$Exchange2013 = New...