General
This code sample retrieves the following parameters of a mail-enabled group:
- Alias
- Simple display name
- Expansion server
- Hide from Exchange address lists
- Send out-of-office message to originator
- Send delivery reports to the group manager
- Send delivery reports to the message originator
- Exchange custom attributes
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
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")
# Bind to the group
$groupDN = "CN=My Group,CN=Groups,DC=domain,DC=com"
$group = $service.OpenObject("Adaxes://$groupDN", $null, $null, 0)
# Get Exchange properties
$groupParams = $group.GetMailParameters()
# The $groupParams variable represents Exchange properties of a mail-enabled group
# Alias
Write-Host "Alias:" $groupParams.Alias
# Simple display name
Write-Host "Simple display name:" $groupParams.SimpleDisplayName
# Expansion server
$expansionServer = $groupParams.ExpansionServer
Write-Host "Expansion server: " -NoNewline
if ($expansionServer -eq $null)
{
Write-Host "Not specified"
}
else
{
Write-Host $expansionServer.DisplayName
}
# Hide from Exchange address lists
Write-Host "Hide from Exchange address lists:" $groupParams.HiddenFromExchangeAddressList
# Send out-of-office message to originator
Write-Host "Send out-of-office message to originator" $groupParams.SendOofMessageToOriginator
# Delivery reports
Write-Host "Delivery reports: " -NoNewline
if ($groupParams.ReportToManager)
{
# Send delivery reports to the group manager
Write-Host "Send to the group manager"
}
elseif ($groupParams.ReportToOriginator)
{
# Send delivery reports to the message originator
Write-Host "Send to message originator"
}
else
{
Write-Host "Do not send"
}
# Custom attributes
$customAttributes = $groupParams.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"
}
See also
- Performing Exchange tasks
- Writing ADSI scripts
- Server-side scripting
- IAdmExchangeMailParametersOps
- IAdmExchangeMailParameters
- IAdmExchangeMailGroupParameters
- Online script repository