Search code examples
powershellcontactspowershell-2.0exchange-server-2010user-defined

Powershell - Custom Attributes in an Exchange Contact


List contacts in "Shared Public Folder":

# First create Outlook object and get the Mapi namespace. 
$Outlook       = New-Object -com Outlook.Application 
$Namespace     = $outlook.GetNamespace("MAPI") 
$PublicFolder  = $Namespace.Folders.Item("Public Folders - [email protected]")
$PublicFolders = $PublicFolder.Folders.Item("All Public Folders")
$AddressBook   = $PublicFolders.Folders.Item("Company Address Book")
$Contacts      = $AddressBook.Items        
foreach ($Contact in $Contacts){
    $Contact.FullName
}

Each contact has a few custom attributes. Such as EmpID, "Contact Type", "IsManager"... I can't seem to figure out how to load the User-Defined property created in Outlook via Powershell.

I've found this post that deals with: Define Custom property, then use that definition to load the custom property... but I'm not sure if that's the right place to be looking, since everything dealing with it that I try gives me errors.


Solution

  • foreach ($Contact in $Contacts){
        $EmpID = $Contact.UserProperties.Find('EmpID').Value
        $Contact.FullName
        $EmpID
    }