General
The following code samples modify properties of a mail-enabled group.
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 group
$groupDN = "CN=MyGroup,CN=Users,DC=example,DC=com"
$group = $service.OpenObject("Adaxes://$groupDN", $null, $null, 0)
# Create an instance of the AdmExchangeMailGroupParameters class
$groupParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailGroupParameters"
# Set Alias
$groupParams.Alias = "%name%"
# Save the changes
$group.SetMailParameters($groupParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_RESOLVEVALUEREFERENCES")
Simple display name
[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=MyGroup,CN=Users,DC=example,DC=com"
$group = $service.OpenObject("Adaxes://$groupDN", $null, $null, 0)
# Create an instance of the AdmExchangeMailGroupParameters class
$groupParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailGroupParameters"
# Set Simple display name
$groupParams.SimpleDisplayName = "%name%(%Info%)"
# Save the changes
$group.SetMailParameters($groupParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_RESOLVEVALUEREFERENCES")
Expansion server
[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=MyGroup,CN=Users,DC=example,DC=com"
$group = $service.OpenObject("Adaxes://$groupDN", $null, $null, 0)
# Create an instance of the AdmExchangeMailGroupParameters class
$groupParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailGroupParameters"
$expansionServerDN = "CN=ExchangeServer,CN=Servers," +
"CN=Exchange Administrative Group (FYDIBOHF23SPDLT)," +
"CN=Administrative Groups,CN=First Organization," +
"CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=example,DC=com"
# Set expansion server
$expansionServer = New-Object "Softerra.Adaxes.Adsi.AdmObjectReference"
$expansionServer.ObjectDN = $expansionServerDN
$groupParams.ExpansionServer = $expansionServer
# Save the changes
$group.SetMailParameters($groupParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")
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 group
$groupDN = "CN=MyGroup,CN=Users,DC=example,DC=com"
$group = $service.OpenObject("Adaxes://$groupDN", $null, $null, 0)
# Create an instance of the AdmExchangeMailGroupParameters class
$groupParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailGroupParameters"
# Hide from Exchange address lists
$groupParams.HiddenFromExchangeAddressList = $true
# Save the changes
$group.SetMailParameters($groupParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")
Send out-of-office message to originator
[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=MyGroup,CN=Users,DC=example,DC=com"
$group = $service.OpenObject("Adaxes://$groupDN", $null, $null, 0)
# Create an instance of the AdmExchangeMailGroupParameters class
$groupParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailGroupParameters"
$groupParams.SendOofMessageToOriginator = $true
# Save the changes
$group.SetMailParameters($groupParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")
Send delivery reports to the group manager
[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=MyGroup,CN=Users,DC=example,DC=com"
$group = $service.OpenObject("Adaxes://$groupDN", $null, $null, 0)
# Create an instance of the AdmExchangeMailGroupParameters class
$groupParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailGroupParameters"
$groupParams.ReportToOriginator = $false
$groupParams.ReportToManager = $true
# Save the changes
$group.SetMailParameters($groupParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")
Send delivery reports to the message originator
[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=MyGroup,CN=Users,DC=example,DC=com"
$group = $service.OpenObject("Adaxes://$groupDN", $null, $null, 0)
# Create an instance of the AdmExchangeMailGroupParameters class
$groupParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailGroupParameters"
$groupParams.ReportToOriginator = $true
$groupParams.ReportToManager = $false
# Save changes
$group.SetMailParameters($groupParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")
Do not send delivery reports
[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=MyGroup,CN=Users,DC=example,DC=com"
$group = $service.OpenObject("Adaxes://$groupDN", $null, $null, 0)
# Create an instance of the AdmExchangeMailGroupParameters class
$groupParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailGroupParameters"
$groupParams.ReportToOriginator = $false
$groupParams.ReportToManager = $false
# Save the changes
$group.SetMailParameters($groupParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")
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 group
$groupDN = "CN=MyGroup,CN=Users,DC=example,DC=com"
$group = $service.OpenObject("Adaxes://$groupDN", $null, $null, 0)
# Create an instance of the AdmExchangeMailGroupParameters class
$groupParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailGroupParameters"
# Set Exchange attribute
$customAttributes = $groupParams.CustomAttributes
$customAttributes.IsModificationEnabled = $true
$customAttributes.SetCustomAttribute(1, "Date Modified: %datetime%")
# Save the changes
$group.SetMailParameters($groupParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")
See also
- Performing Exchange tasks
- Writing ADSI scripts
- Server-side scripting
- IAdmExchangeMailParametersOps
- IAdmExchangeMailParameters
- IAdmExchangeMailGroupParameters
- Online script repository