Delivery management
This code sample retrieves the following delivery management settings for a mail-enabled group:
- Accept messages from
- Reject messages from
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
# Get message delivery restrictions
$messageDeliveryRestrictions = $groupParams.MailFlowSettings.MessageDeliveryRestrictions
# Get list of accepted senders
$acceptMessagesFrom = $messageDeliveryRestrictions.AcceptMessagesOnlyFrom
# Accept messages only from senders inside my organization
$requireSenderAuthentication = $messageDeliveryRestrictions.RequireSenderAuthentication
if (($acceptMessagesFrom.Count -eq 0) -and (-not($requireSenderAuthentication)))
{
Write-Host "Accept messages from: All senders"
}
elseif ($requireSenderAuthentication)
{
Write-Host "Accept messages from: Only senders inside my organization"
}
else
{
Write-Host "Accept messages from:"
for ($i = 0; $i -lt $acceptMessagesFrom.Count; $i++)
{
$object = $acceptMessagesFrom.GetItem($i, [ref]"ADS_PROPERTY_NONE")
Write-host "`t" $object.DisplayName
}
}
# Get list of rejected senders
$rejectMessagesFrom = $messageDeliveryRestrictions.RejectMessagesFrom
if ($rejectMessagesFrom.Count -eq 0)
{
Write-Host "Reject messages from: No senders"
}
else
{
Write-Host "Reject messages from:"
for ($i = 0; $i -lt $rejectMessagesFrom.Count; $i++)
{
$object = $rejectMessagesFrom.GetItem($i, [ref]"ADS_PROPERTY_NONE")
Write-host "`t" $object.DisplayName
}
}
See also
- Performing Exchange tasks
- Writing ADSI scripts
- Server-side scripting
- IAdmExchangeMailParametersOps
- IAdmExchangeMailParameters
- IAdmExchangeMailGroupParameters
- IAdmExchangeMailFlowSettings
- Online script repository