Skip to content

Modifying groups

The following code sample modifies the Description property of 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)

# Update the group
$group.Put("description", "My Description")
$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 -Description "My Description" -Server "domain.com" `
    -AdaxesService localhost

The following code sample modifies the Group Type property of 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)

# Update the group
[Softerra.Adaxes.Interop.Adsi.ADS_GROUP_TYPE_ENUM]$groupType =
    "ADS_GROUP_TYPE_GLOBAL_GROUP, ADS_GROUP_TYPE_SECURITY_ENABLED"

$group.Put("groupType", [Int32]$groupType)
$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 -GroupCategory Security `
    -GroupScope Universal, -Server "domain.com" -AdaxesService localhost

See also