Find group membership

Hi Jason,

I am using your script to find the nested group membership at the below link:

however on line 93:

Foreach ($Member in (Get-ADGroupMember -Identity $Identity))

It does not find group members from groups in other domains. I added a paramter to except the domain name also in this line.

However, I get the below error:

Cannot compare “CN=AdminGroup,OU=Sales,DC=lab,DC=net” because it is not IComparable.
At line:118 char:13

  • If ($Group -gt 0){
  • CategoryInfo : InvalidOperation: (:slight_smile: , RuntimeException
  • FullyQualifiedErrorId : NotIcomparable

<hr />

However I have permission on this group and can see it from the GUI. This happens even I do not modify the script and run it. Any way to resolve this issue? This is not a permission issue.

Hey TechSavy,

If($Group.Count -gt 0){

Looks like a typo occurred.

Thanks Jason. Using the script, the groups are showing up within the { } brackets. Instead of the { }, how can we separate the nested groups into different columns to be output to a csv file?

Hi Jason,

In your function I added a parameter [string]$server and updated line 93 to accept this parameter as shown below:

foreach($member in (Get-ADGroupMember -identity $identity -Server $server)

I am running the below code:

foreach($group in ( Import-csv C:\Users\grouplist.csv))
NestedGroups=Get-NestedADGroupMember -identity $group.GroupName -Server $group.DomainName -Listgroups | Select -ExpandProperty Name
$Results | Export-csv C:\Users\results.csv -NoTypeInformation -Append

However the groups which have more than one nested groups are showing as below:

AdminGroup System.Object

How to resolve this?