PowerTip: List Outlook Contacts with PowerShell

Summary: Use Windows PowerShell to list contacts in Microsoft Outlook.

Hey, Scripting Guy! Question How can I use Windows PowerShell to programmatically connect to Outlook to get the Contacts list?

Hey, Scripting Guy! Answer Connect by using ComObject, and select the objects you need:

$Outlook=NEW-OBJECT –comobject Outlook.Application


$Contacts | Format-Table FullName,MobileTelephoneNumber,Email1Address

Comments (5)

  1. jrv says:

    Nope. Too easy. Now load them into SharePoint on O365. It takes about three more steps.

  2. TimA says:

    What I am having problems with is. I am trying to do some data mining, with something like this:

    #This is the Outlook "get your inbox" stuff that store it all in a $inbox variable.
    $olFolderInbox = 6
    $outlook = new-object -com outlook.application;
    $ns = $outlook.GetNameSpace("MAPI");
    $inbox = $ns.GetDefaultFolder($olFolderInbox)

    #Loops through the variable and outputs the fields you select to the CSV.
    foreach ($b in $inbox.Items)
    $b | select sendername,subject,Senton | export-csv -Path $outputFile -NoTypeInformation -Append

    Seems to me that the number 6 equals INBOX.
    Just like in your script 10 equals Contacts.

    I would like to run a command like what you have here, that will identify the numbers of each folder within a users mailbox.

    for instance:
    John Doe
    -Sent Items
    -Deleted Items

    So a script I would run would tell me what number to use for the subfolder in Inbox called 2014

  3. Frank says:

    How can I export this contacts to msg files?

  4. Jon says:

    How would I delete the contacts? I tried changing the last line to "$Contacts | Remove-Item" but it didn’t work. The user has 63,000 contacts that were sync’d with CRM so doing this manually would take too long. Any suggestions?

  5. ENUMER says:

    # loop throughinbox and export selected properties
    $inbox.Items |
    select sendername,subject,Senton |
    export-csv -Path $outputFile -NoTypeInformation -Append

    # get all default folder names and get enum for ‘Sent Items’
    add-type -AssemblyName Microsoft.Office.Interop.Outlook

Skip to main content