M365 - Export all contacts from my users

Copper Contributor

Dear awesome people of the community,

 

I’ve been trying for multiple days together with someone else (that person is more technical) to make a script that can export all contacts of my user’s mailboxes (I’m Global Administrator) because I’m trying to solve longtime issues with bad central contact management. And to help those people from a distance, I want to export their contacts so I can make a delta of our central database to help them separate their personal work related contacts from our DB.

 

We have been trying to use some scripts from other people but apparently due to language settings we ended up with some issues. 

 

The script wouldn’t need to be full automatic, I would have no issues running the same script 35 times manually to ensure I can help the users from a distance with this problem (it’s more than 3.000 contacts that need to be verified)

 

We tried script from https://github.com/gscales/Powershell-Scripts/tree/master/EWSContacts but I’m open to everything at this point.

 

I hope anyone has some experience with this. Love to hear from you. Thanks a bunch in advance!

 

Kind regards,

S.G.

5 Replies
"We ended up with some issues" What issues, what does work and what doesn't;?

@Harm_Veenstra Thank you for replying. It seemed that we got the script only functioning on my account, most probably because of the language. (me as admin has everything in EN, while everyone else has their locale in NL).

SteinG645_0-1675323527968.png

Using GraphAPI my colleague seemed to get the same issues, no "contacts" store was found for any NL users

https://learn.microsoft.com/en-us/graph/api/user-list-contacts?view=graph-rest-1.0&tabs=http

https://learn.microsoft.com/en-us/graph/api/contactfolder-get?view=graph-rest-beta&tabs=powershell

 

Do you have any experience using this script, or any other script/GraphAPI for extracting contactpersonen (dutch for Contacts) store and getting that export in a format that is usable in Excel?

I don't have experience in this particular action yet, but can you specify the name of the contact folder in the script? Check for contacts folder, if not present use contactpersonen?
My collegue (far more technical than me) wasn't able to find a way via the script to change the name for the searched store (from contacts to contactpersonen) 😞
Even when you do a get-mailbox you can check for prefered language.

But that on the side.

So if i get it right you want to export from every user there contacts and combine them ?

You could use the graph api.
https://learn.microsoft.com/en-us/graph/api/user-list-contacts?view=graph-rest-1.0

With the first you will get the name: contacts of contactpersonen already in a variable so it doesn't matter then anymore.