Creating organizational units

The following code sample creates an organizational unit.

ADSI
[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 domain
$domainDN = "DC=domain,DC=com"
$domain = $service.OpenObject("Adaxes://$domainDN", `
    $null, $null, 0)

# Create a new organizational unit
$ou = $domain.Create("organizationalUnit", "OU=New Organizational Unit")
$ou.SetInfo()
PowerShell
Import-Module Adaxes

$domainDN = "DC=domain,DC=com"

New-AdmOrganizationalUnit -Name "New Organizational Unit" -Path $domainDN `
    -Server "domain.com" -AdaxesService localhost

See also