Descobrimos que o item crucial faltante era a propriedade "showinaddressbook".
Este artigo explica como funciona: link
The showInAddressBook attribute has two purposes. The first is to let people see the entry listed in the address list by means of Messaging Application Programming Interface (MAPI) client, such as Microsoft Outlook. The second purpose is to allow users to "resolve a name" on a MAPI client.
Embora o artigo se refira ao RUS (Serviço de Atualização de Destinatário), que não existe mais desde o Exchange 2007, acho que o processo subjacente para o correio que habilita um objeto ainda é o mesmo.
Então, basicamente, para criar um contato habilitado para email sem usar os cmdlets do Exchange 2013, fiz algo assim:
$alias = "ADDR-00001"
$email = "[email protected]"
$first = "Joe"
$last = "Doe"
$displayname = "DOE Joe"
$department = "My Dept."
$office = "My Office"
$phone = "55554448934"
$proxyAddresses = "SMTP:[email protected]"
$DestinationOU = "OU=contact,OU=example,DC=corp,DC=example,DC=com"
$AddressBook = "CN=Default Global Address List,CN=All Global Address Lists,CN=Address Lists Container,CN=Example-Org,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=corp,DC=example,DC=com","CN=All Contacts,CN=All Address Lists,CN=Address Lists Container,CN=Example-Org,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=corp,DC=example,DC=com"
$Attributes = @{'displayName' = $displayname; 'GivenName' = $first; 'SN' = $last; 'Department' = $department; 'physicalDeliveryOfficeName' = $office; 'telephoneNumber' = $phone; 'mail' = $email; 'mailnickname' = $alias; 'targetaddress' = $email; 'proxyAddresses' = $proxyAddresses; 'showinaddressbook' = $AddressBook;}
New-AdObject -Type Contact -Name $displayname -Path $DestinationOU -OtherAttributes $Attributes
O objeto resultante ainda não tem o valor LegacyExchangeDN
e tem um peculiar ExchangeVersion
, mas a propriedade AddressListMembership
agora está preenchida.
Get-Mailcontact "[email protected]" | select displayName, RecipientType, LegacyExchangeDN, ExchangeVersion, AddressListMembership| fl
DisplayName : DOE Joe
RecipientType : MailContact
LegacyExchangeDN :
ExchangeVersion : 0.0 (6.5.6500.0)
AddressListMembership : {\All Contacts, \Default Global Address List}