Mailbox Usage

The following code sample modifies Storage Quotas for a mailbox.

[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=example,DC=com"
$user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0)

# Create an instance of the 'AdmExchangeMailboxParameters' class
$mailboxParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailboxParameters"

$storageQuotas = $mailboxParams.StorageQuotas
$storageQuotas.IsModificationEnabled = $true
$storageQuotas.UseDatabaseQuotaDefaults = $false

# Issue Warning Quota
$issueWarningQuota = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmByteQuantifiedSize"
$issueWarningQuota.SetMBytes(100)
$storageQuotas.IssueWarningQuota = $issueWarningQuota

# Prohibit Send Quota
$prohibitSendQuota = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmByteQuantifiedSize"
$prohibitSendQuota.SetMBytes(150)
$storageQuotas.ProhibitSendQuota = $prohibitSendQuota

# Prohibit Send and Receive Quota
$prohibitSendReceiveQuota = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmByteQuantifiedSize"
$prohibitSendReceiveQuota.SetMBytes(200)
$storageQuotas.ProhibitSendReceiveQuota = $prohibitSendReceiveQuota

# Save changes
$user.SetMailParameters($mailboxParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")

The following code sample sets Deleted Item Retention for a mailbox.

[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=example,DC=com"
$user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0)

# Create an instance of the 'AdmExchangeMailboxParameters' class
$mailboxParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailboxParameters"

$storageQuotas = $mailboxParams.StorageQuotas
$storageQuotas.IsModificationEnabled = $true
$storageQuotas.UseDatabaseRetentionDefaults = $false

# Retain deleted items for 120 days
$storageQuotas.RetainDeletedItemsFor = 120

# Retain deleted items until next database backup. 
$storageQuotas.RetainDeletedItemsUntilBackup = $true

# Save changes
$user.SetMailParameters($mailboxParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")

See also