Export All Dynamic groups with its membership rules

Hello Guys,

I'm in need of a powershell script to get all dynamic groups in our environment with the membership rules. 

I can get the list using the below script but the membership rules i get is the membership rules plus GUID & SID of the OU's with it which makes it difficult to manage

Import-Module ActiveRolesManagementShell
Get-QADGroup -Proxy -Dynamic $true -DontUseDefaultIncludedProperties -IncludedProperties cn, edsaDGConditionsList |
Select-Object -Property cn, edsadgconditionslist |
Export-Csv -Path C:\TEMP\DynamicGroups.csv -NoTypeInformation

the below script can get just the membership rule perfectly but of single groups

$MU = (get-qadgroup $Groupname -Proxy).DirectoryEntry.MembershipRuleCollection

$MU | select base, Filter, Type | fl

How can i combine both the scripts & get the desired inputs, i want the name of the groups and with the exact membership rules starting with e.g. "(&(objectclass= "

Parents
  • Try this:

    Get-QADGroup -Proxy -Dynamic $true -DontUseDefaultIncludedProperties -IncludedProperties cn, edsaDGConditionsList | foreach {

    $GroupCN = $_.CN

    $MemberRuleDetails = $_.DirectoryEntry.MembershipRuleCollection | select base, Filter, Type

    # Depending on PoSh version, use ONE of the two following lines to add the CN to the output object:

    $MemberRuleDetails | Add-Member -NotePropertyName CN -NotePropertyValue $GroupCN

    $MemberRuleDetails | Add-Member -MemberType NoteProperty -Value $GroupCN -Name CN

    $MemberRuleDetails | select cn,base,Filter,Type | export-csv C:\TEMP\DynamicGroups.csv -NoTypeInformation -append

    }

  • Hey Johnny, it worked for me too. Thank you

    Need little help, instead of base/Fully qualified DN can we get only DN of the member of that dynamic group?

      • Example
        • DN
          • CN=AG_EMIP_USERS,OU=~ Test Security Groups,DC=Test,DC=local
        • FQDN
          • //servername.Test.local/caCN=AG_EMIP_USERS,OU=~ TestSecurity Groups,DC=Test,DC=local

      

Reply
  • Hey Johnny, it worked for me too. Thank you

    Need little help, instead of base/Fully qualified DN can we get only DN of the member of that dynamic group?

      • Example
        • DN
          • CN=AG_EMIP_USERS,OU=~ Test Security Groups,DC=Test,DC=local
        • FQDN
          • //servername.Test.local/caCN=AG_EMIP_USERS,OU=~ TestSecurity Groups,DC=Test,DC=local

      

Children
No Data