E-mail addresses
This code sample retrieves the following parameters of an Exchange mailbox:
- E-mail addresses
- Automatically update e-mail addresses based on e-mail address policy
In the below code sample, the $mailboxParams variable represents properties of an Exchange mailbox. To retrieve the properties, use the IAdmExchangeMailParametersOps::GetMailParameters method.
How
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")
# Connect to the Adaxes service
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")
# Bind to the user
$userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"
$user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0)
# Get Exchange properties
$mailboxParams = $user.GetMailParameters()
# The $mailboxParams variable represents properties of an Exchange mailbox
# Email addresses
Write-Host "E-mail addresses:"
$emailAddresses = $mailboxParams.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:" `
$mailboxParams.EmailAddressPolicyEnabled
See also
- Performing Exchange tasks
- Writing ADSI scripts
- Server-side scripting
- IAdmExchangeMailParametersOps
- IAdmExchangeMailParameters
- IAdmExchangeMailboxParameters
- IAdmExchangeProxyAddressModificationCollection
- Online script repository