SOLVED

Exchange Online - Extract user's contacts with PS

Copper Contributor

Hi all,

 

I have spent a fair amount of time trying to find a Powershell script enabling me to extract the contacts of an O365 Exchange account to a local file. It has proven to be somewhat of a challenge.

 

I found this script https://gallery.technet.microsoft.com/office/How-to-export-a-mailboxs-2dd7247a, which upon first observation should be able to produce what I want, but the script doesn't work, it fails indicating an Autodiscover error.

 

C:\Scripts\EXOGetContacts.ps1 : The Autodiscover service returned an error.
Au caractère Ligne:1 : 1
+ .\EXOGetContacts.ps1
+ ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [EXOGetContacts.ps1], AutodiscoverRemoteException
    + FullyQualifiedErrorId : AutodiscoverRemoteException,EXOGetContacts.ps1

 

Does anyone have any suggestions, either for the above error, or for an alternative methode to extract contacts using Powershell?

 

Much appreciated, kind regards.

2 Replies
best response confirmed by Jaap Hoetmer (Copper Contributor)
Solution

The script seems to have some undefined variables, and thus fails to connect. You can put something like this:

 

$exchangeService.Url = "https://outlook.office365.com/EWS/Exchange.asmx"

 

I'd recommend using Glen's EWSContacts module for any Contacts related operations: https://github.com/gscales/Powershell-Scripts/tree/master/EWSContacts

Hi Vasil,

 

Thanks for your suggestion, it turned out to be a problem with autodiscovery not finding the correct URL, the suggestion you gave by bypassing autodiscovery works. I'll try to understand why it doesn't work using Autodiscovery.

 

I'll also give Glen's EWSContacts script a try.

 

Much appreciated, kind regards,

Jaap

1 best response

Accepted Solutions
best response confirmed by Jaap Hoetmer (Copper Contributor)
Solution

The script seems to have some undefined variables, and thus fails to connect. You can put something like this:

 

$exchangeService.Url = "https://outlook.office365.com/EWS/Exchange.asmx"

 

I'd recommend using Glen's EWSContacts module for any Contacts related operations: https://github.com/gscales/Powershell-Scripts/tree/master/EWSContacts

View solution in original post