Search code examples
powershellcsvexchange-serverpst

Export all mailboxes' contacts to CSV


Is there a way to export all the contacts for each mailboxes in Exchange 2010 to a format easy to import to MS SQL? (i.e. CSV)

So far I got this working but a PST format is absolutely pointless:

foreach ($i in (Get-Mailbox)) { New-MailboxExportRequest -Mailbox $i -FilePath “\\computer\c$\pst\$($i.Alias).pst” -IncludeFolders “#Contacts#” -ExcludeDumpster}

The objective is to automate the task so we can run it each week or so.


Solution

  • You can use EWS (Exchange web services) to access and then export Mailbox content there are a bunch of examples for exporting contacts eg

    https://github.com/wadimk/PowerShell-Scripting/blob/master/PowerShell%20Script%20Project/EWS-Export-Contacts.ps1

    https://gallery.technet.microsoft.com/office/Export-Contacts-from-OWA-9f8cc0f2

    http://gsexdev.blogspot.com.au/2014/02/exporting-contacts-to-csv-file-using.html