Hi Jason,
I am using your script to find the nested group membership at the below link:
https://github.com/JasonRobertson/PowerShell/blob/master/Get-NestedADGroupMember/Get-NestedADGroupMember.ps1
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: ( , 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:
@Results=@()
foreach($group in ( Import-csv C:\Users\grouplist.csv))
{
$obj=[PSCustomObject]@{
GroupName=$group.GroupName
NestedGroups=Get-NestedADGroupMember -identity $group.GroupName -Server $group.DomainName -Listgroups | Select -ExpandProperty Name
}
$Results+=$Obj
}
$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?