General

This code sample outputs the following parameters of an Exchange mailbox:

  • Alias
  • Simple display name
  • Hide from Exchange address lists
  • Exchange custom attributes
  • Mailbox database name
  • Archive database name

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

# Alias
Write-Host "Alias:" $mailboxParams.Alias

# Simple display name
Write-Host "Simple Disaply Name:" $mailboxParams.SimpleDisplayName

# Hide from Exchange address lists
Write-Host "Hide from Exchange address lists:" $mailboxParams.HiddenFromExchangeAddressList

# Custom attributes
$customAttributes = $mailboxParams.CustomAttributes
Write-Host "Custom attributes"
for ($i = $customAttributes.MinIndex; $i -le $customAttributes.MaxIndex; $i++)
{
    $attributeName = $customAttributes.BuildAttributeName($i)
    $attributeValue = $customAttributes.GetCustomAttribute($i) 
    Write-Host "`t$attributeName`: $attributeValue"    
}

# Mailbox database name
Write-Host "Mailbox database:" $mailboxParams.StorageDatabase

# Archive database name
Write-Host "Archive database:" $mailboxParams.MailboxFeatures.GetItemByType("
  ADM_EXCHANGE_MAILBOXFEATURETYPE_ARCHIVE").DatabaseName

See also