Skip to content

Renaming Organizational Units

The following code sample renames an Organizational Unit.

[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 Organizational Unit
$ouDN = "OU=My OU,DC=domain,DC=com"
$ou = $admService.OpenObject("Adaxes://$ouDN", $NULL, $NULL, 0)

# Rename the Organizational Unit
$ou.Put("name", "New Name")
$ou.SetInfo()
Import-Module Adaxes

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

Rename-AdmObject -Identity $identity -NewName "New Name" `
    -Server "domain.com" -AdaxesService localhost

See also