PowerShell - Getting Contacts From A Specific Mailbox

MichaelL369 1 Reputation point
2021-03-15T01:32:24.397+00:00

Using PowerShell, when I connect to Exchange with my credentials (I'm an admin) and use Get-Contact, I get all the contacts defined under Exchange->Recipients->Contacts. However, what I want to do is pull the actual contacts defined within a user's account. If I connect to Exchange with the mailbox's credentials rather than mine, I do not have access to the Get-Contact command. I'm not a PowerShell expert, so I'm not sure if this is done with impersonation, Get-Mailbox or some other method. How do I accomplish what I am trying to do? Thanks

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,389 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Rich Matheisen 45,096 Reputation points
    2021-03-15T02:09:40.843+00:00

    If this is for an on-premises Exchange, try the New-MailboxExportRequest cmdlet. Be sure to read the cmdlet's help and assign yourself the correct role. The results will be a PST.

    There are other ways, too: some-of-the-many-ways-to-export-outlook-contacts
    export-a-users-exchange-online-contact-list-folder-with-graph-api

    For Exchange Online, using Get-RESTMethod would probably be the fastest way to the contacts, though: oneliner-mailbox-access-in-powershell.html

    0 comments No comments

  2. MichaelL369 1 Reputation point
    2021-03-15T13:44:43.193+00:00

    Thank you for your response. I was able to export the list using the script located in some-of-the-many-ways-to-export-outlook-contacts,

    However, when I spoke about getting contacts from a specific user's mailbox I failed to mention the need to update them as well. So if anyone knows of a solution that works for listing/exporting and updating, please let me know.

    0 comments No comments

  3. Rich Matheisen 45,096 Reputation points
    2021-03-15T14:18:24.057+00:00

    Something like this? powershell-bulk-change-contacts

    0 comments No comments