Skip to content

E-mail addresses

This code sample retrieves the following parameters of a mail-enabled group:

  • Email addresses
  • Automatically update e-mail addresses based on e-mail address policy

Note

In the below code sample, the $groupParams variable represents Exchange properties of a mail-enabled group. To retrieve the properties, use the IAdmExchangeMailParametersOps::GetMailParameters method.

How
[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 group
$groupDN = "CN=My Group,CN=Users,DC=domain,DC=com"
$group = $admService.OpenObject("Adaxes://$groupDN", $NULL, $NULL, 0)

# Get Exchange properties
$groupParams = $group.GetMailParameters()
# The $groupParams variable represents Exchange properties of a mail-enabled group

# Email addresses
Write-Host "E-Mail Addresses:"
$emailAddresses = $groupParams.EmailAddresses

for ($i = 0; $i -lt $emailAddresses.Count; $i++)
{
    $emailAddress = $emailAddresses.GetAddress($i,[ref]"ADS_PROPERTY_NONE")
    Write-Host "`t$emailAddress"
}

# Automatically update e-mail addresses based on e-mail address policy
Write-Host "Automatically update e-mail addresses based on e-mail address policy:" `
$groupParams.EmailAddressPolicyEnabled

See also