In my previous posts on EWS we worked on how to move, remove, export emails items, in this post I will demonstrate how we can work with user Contacts and export the contact in CSV or fetch the contact details.
If you are following my previous post then you would know we just need to access the user Contacts folder and load the items in it with the property set and then get the data we need.
$ContactsFolderid= new-object Microsoft.Exchange.WebServices.Data.FolderId `
$items = $service.FindItems($ContactsFolder.ID,$view)
Most of the data is easily available when it comes to contacts but there are few attributes where we needs to go into the little deep.
So let me talk about how do we work with these attribute and get the data from each member.
Below is the snap shot of a single contact.
You can get it from collection using below method and then check what all field you need and then add the same into the table.
So lets see how we get the data from the attribute with Dictionary object.
If you do “$items.Items | get-member” on any dictionary object you will be able to see the method and ParameterizedProperty.
The best way to get the member for the item is just put the highlighted string in google and check the msdn link for detailed member list.
Like below link for IMAddress
Now you know the member key name we can fetch the data from the member.
The same way you can fetch data from other attributes, below I have put a PowerShell script for full code review, I hope you find this post informative, your feedback and suggestions are welcome in comment section.