Skip to content

Modifying Organizational Units

The following code sample modifies the Managed By property of an Organizational Unit.

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

The following code sample modifies
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to the Organizational Unit
$ouDN = "OU=Organizational Unit,DC=domain,DC=com"
$ou = $admService.OpenObject("Adaxes://$ouDN", $NULL, $NULL, 0)

$managedByDN = "CN=My Group,CN=Users,DC=domain,DC=com"

# Update the Organizational Unit
$ou.Put("managedBy", $managedByDN)
$ou.SetInfo()
Import-Module Adaxes

$identityOU = "OU=Organizational Unit,DC=domain,DC=com"  # DN
# $identityOU = "{EB5FEB21-E648-42AD-B86C-89D3C6807953}" # GUID

$identityManagedBy = "MyGroup" # sAMAccountName
# $identityGroup = "CN=My Group,CN=Users,DC=domain,DC=com"  # DN
# $identityGroup = "{D4BD8631-FD29-4E34-A77B-3505B7D66BA5}" # GUID
# $identityGroup = "S-1-5-21-573937-2149998-410785" # SID


Set-AdmOrganizationalUnit -Identity $identityOU -ManagedBy $identityManagedBy `
    -Server "domain.com" -AdaxesService localhost

See also