Book Image

Microsoft Exchange 2010 PowerShell Cookbook

Book Image

Microsoft Exchange 2010 PowerShell Cookbook

Overview of this book

Table of Contents (22 chapters)
Microsoft Exchange 2010 PowerShell Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Working with impersonation


When building PowerShell scripts that leverage the EWS Managed API, we can use impersonation to access a user's mailbox on their behalf without having to provide their credentials. In order to utilize impersonation, we need permissions inside the Exchange organization, and then we need to configure the ExchangeService connection object with the impersonated user ID. In this recipe, you'll learn how to assign the permissions and write a script that uses EWS impersonation.

Getting ready

You will need to use the Exchange Management Shell in this recipe in order to assign permissions for Application Impersonation.

How to do it...

The first thing you need to do is assign your account the ApplicationImpersonation RBAC role from the Exchange Management Shell:

New-ManagementRoleAssignment -Role ApplicationImpersonation `
-User administrator

After we've been granted the permissions, we need to import the EWS Managed API assembly and configure the ExchangeService connection object...