Skip to content

Mailbox Usage

The following code sample modifies Storage Quotas for a mailbox.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to the user
$userDN = "CN=John Smith,CN=Users,DC=example,DC=com"
$user = $admService.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
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to the user
$userDN = "CN=John Smith,CN=Users,DC=example,DC=com"
$user = $admService.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