Creating mailboxes

The following code sample creates a mailbox for a user.

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

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

$userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"
$alias = "%username%"
$mailboxDatabaseDN =
    "CN=DB 1,CN=Databases,CN=Exchange Administrative Group," +
    "CN=Administrative Groups,CN=First Organization,CN=Microsoft Exchange," +
    "CN=Services,CN=Configuration,DC=domain,DC=com"

# Bind to the user
$user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0)

# Create mailbox
$user.CreateMailbox($alias, "Adaxes://$mailboxDatabaseDN")

See also