Skip to content

Mail-enabling users

The following code sample mail-enables a user.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to the user
$userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"
$user = $admService.OpenObject("Adaxes://$userDN", $NULL, $NULL, 0)

# Mail-enable the user
$alias = "%samAccountName%" # Alias
$externalMailAddress = "Jsmith@domain.com" # External e-mail address
$externalMailAddressType = "SMTP" # External e-mail address type

$user.MailEnable($alias, $externalMailAddress, $externalMailAddressType, $NULL)

See also