Script Repository

Save list of group members to multi-valued property

January 29, 2021

The script saves a list of members of an AD group to a multi-valued property of the group. The list includes both direct and indirect group members.


  • $membersProperty - specifies the LDAP name of the AD property that stores the member list. For this purpose, we recommend using an Adaxes virtual property, e.g. CustomAttributeMultiValue1. Such properties are not stored in AD, but can be used the same as any other properties of AD objects.
Edit Remove
$membersProperty = "adm-CustomAttributeTextMultiValue1" # TODO: modify me

$groupMemberList = @()

# Get group members
    $memberGuidsBytes = $Context.TargetObject.GetEx("adm-MembersGuid")
    $memberGuidsBytes = $NULL # The group has no members

# Get member names
if ($memberGuidsBytes -ne $NULL)
    foreach ($memberGuidBytes in $memberGuidsBytes)
        $memberGuid = New-Object "System.Guid" (, $memberGuidBytes)
        $memberGuid = $memberGuid.ToString("B")
        $memberPath = "Adaxes://<GUID=$memberGuid>"
        $member = $Context.BindToObject($memberPath)
        $memberName = [Softerra.Adaxes.Utils.ObjectNameHelper]::GetObjectName($member, 'IncludeParentPath')
        $groupMemberList += $memberName

# Save to property
$Context.TargetObject.Put($membersProperty, $groupMemberList)

Comments ( 0 )
No results found.
Leave a comment

Related Scripts