Renaming organizational units

The following code sample renames 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 organizational unit
$ouDN = "OU=My OU,DC=domain,DC=com"
$ou = $service.OpenObject("Adaxes://$ouDN", $null, $null, 0)

# Rename the organizational unit
$ou.Put("name", "New Name")
$ou.SetInfo()
PowerShell
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