Skip to content

Renaming groups

The following code sample renames a group.

[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 group
$groupDN = "CN=SalesGroup,CN=Users,DC=domain,DC=com"
$group = $admService.OpenObject("Adaxes://$groupDN", $NULL, $NULL, 0)

# Rename group
$group.Put("name", "My Group")
$group.SetInfo()
Import-Module Adaxes

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

Rename-AdmObject -Identity $identity -NewName "My Group" `
    -Server "domain.com" -AdaxesService localhost

The following code sample renames a group and modifies the Group Name (pre-Windows 2000) property of the group.

[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 group
$groupDN = "CN=SalesGroup,CN=Users,DC=domain,DC=com"
$group = $admService.OpenObject("Adaxes://$groupDN", $NULL, $NULL, 0)

# Update group
$group.Put("name", "My Group")
$group.Put("sAMAccountName", "MyGroup")
$group.SetInfo()
Import-Module Adaxes

$identity = "SalesGroup" # sAMAccountName
# $identity = "CN=SalesGroup,CN=Users,DC=domain,DC=com"  # DN
# $identity = "{EB5FEB21-E648-42AD-B86C-89D3C6807953}" # GUID
# $identity = "S-1-5-21-573937-2149998-410785" # SID

Set-AdmGroup -Identity $identity -Replace @{name='My Group'} `
    -SamAccountName "MyGroup" -Server "domain.com" `
    -AdaxesService localhost

See also