General
The following code samples modify properties of a mail-enabled contact.
Alias
[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 contact
$contactDN = "CN=My Contact,CN=Contacts,DC=domain,DC=com"
$contact = $service.OpenObject("Adaxes://$contactDN", $null, $null, 0)
# Create an instance of the AdmExchangeMailContactParameters class
$contactParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailContactParameters"
# Set Alias
$contactParams.Alias = "%firstname,1%%lastname%"
# Save the changes
$contact.SetMailParameters($contactParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_RESOLVEVALUEREFERENCES")
Use MAPI rich text format
[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 contact
$contactDN = "CN=My Contact,CN=Contacts,DC=domain,DC=com"
$contact = $service.OpenObject("Adaxes://$contactDN", $null, $null, 0)
# Create an instance of the AdmExchangeMailContactParameters class
$contactParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailContactParameters"
# Format for messages in the RTF format:
# Use default settings of the client computer from which the message is sent
$contactParams.UseMapiRichTextFormat = "ADM_EXCHANGE_USEMAPIRICHTEXTFORMATTYPE_USEDEFAULTSETTINGS"
$contactParams.UseMapiRichTextFormatModificationEnabled = $true
# Save the changes
$contact.SetMailParameters($contactParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_RESOLVEVALUEREFERENCES")
Hide from Exchange address lists
[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 contact
$contactDN = "CN=My Contact,CN=Contacts,DC=domain,DC=com"
$contact = $service.OpenObject("Adaxes://$contactDN", $null, $null, 0)
# Create an instance of the AdmExchangeMailContactParameters class
$contactParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailContactParameters"
# Hide from Exchange address lists
$contactParams.HiddenFromExchangeAddressList = $true
# Save the changes
$contact.SetMailParameters($contactParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_RESOLVEVALUEREFERENCES")
Exchange custom attributes
[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 contact
$contactDN = "CN=My Contact,CN=Contacts,DC=domain,DC=com"
$contact = $service.OpenObject("Adaxes://$contactDN", $null, $null, 0)
# Create an instance of the AdmExchangeMailContactParameters class
$contactParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailContactParameters"
# Set Exchange attribute
$customAttributes = $contactParams.CustomAttributes
$customAttributes.IsModificationEnabled = $true
$customAttributes.SetCustomAttribute(1, "Date Modified: %datetime%")
# Save the changes
$contact.SetMailParameters($contactParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_RESOLVEVALUEREFERENCES")
See also
- Performing Exchange tasks
- Writing ADSI scripts
- Server-side scripting
- IAdmExchangeMailParametersOps
- IAdmExchangeMailParameters
- IAdmExchangeMailContactParameters
- Online script repository