Delegation
The following code sample retrieves the following permissions on a mail-enabled group:
- Send As delegates
 - Send on Behalf Of delegates
 
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
# Send As delegates
$sendAs = $groupParams.SendAs
if ($sendAs.Count -eq 0)
{
    Write-Host "Send As: Not delegated"
}
else
{
    Write-Host "Send As:"
    for ($i = 0; $i -lt $sendAs.Count; $i++)
    {
        $object = $sendAs.GetItem($i, [ref]"ADS_PROPERTY_NONE")
        Write-host "`t" $object.DisplayName
    }
}
# Send on Behalf Of delegates
$sendOnBehalfOf = $groupParams.GrantSendOnBehalfTo
if ($sendOnBehalfOf.Count -eq 0)
{
    Write-Host "Send on Behalf Of: Not delegated"
}
else
{
    Write-Host "Send on Behalf Of:"
    for ($i = 0; $i -lt $sendOnBehalfOf.Count; $i++)
    {
        $object = $sendOnBehalfOf.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
 - Online script repository