Link to home
Start Free TrialLog in
Avatar of msidnam
msidnamFlag for United States of America

asked on

Export Contacts Exchange Online Powershell

I have a need to be able to export contacts for specific users using powershell. I've tried the scripts here but the don't seem to work:

https://community.spiceworks.com/topic/2155223-powershell-office-365-export-user-s-contacts-to-csv

https://gallery.technet.microsoft.com/office/How-to-export-a-mailboxs-2dd7247a

The one from spiceworks doesnt give me any errors, but the csv it creates has no data.

The one from the technet gallery gives me an autodiscovery error and I'm not sure how to fix that.

Does anyone else have a tried and true way of exporting contacts using powershell and exchange online?

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of Vasil Michev (MVP)
Vasil Michev (MVP)
Flag of Bulgaria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of msidnam

ASKER

Thank you.

From what I can gather, I will need the passwords for any user that I want to export the contacts? If so, does anyway exist to export contacts for users by putting in a global admin or exchange admin account thats connected to O365/Exchange online?
You dont need their password, but you need to run the script as a person with sufficient permissions. Which reads: either having a Full Access permissions over the mailbox from which you want to export contacts, or having the EWS impersonation impersonation role granted on the account. Here's an article on the latter: https://docs.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-configure-impersonation
Avatar of msidnam

ASKER

This worked. I added the ApplicationImpersonation to a user and I am able to get the contacts. now to find a way to export all of them at once to a file instead of one by one.

thank you.