Deleting mailboxes
The following code sample deletes a user's 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=domain,DC=com"
$user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0)
# Delete mailbox
$user.DeleteMailbox()
See also
- Performing Exchange tasks
- IAdmExchangeMailboxOps
- Writing ADSI scripts
- Server-side scripting
- Online script repository