How to find groups that belongs to a specific AD in Powershell

Lulzim Kamilji 0 Reputation points
2023-04-27T12:05:45.15+00:00

Hi,

I have now tried to search the entire internet for help with no luck.

I am trying to find the groups that belongs to a specific AD group we have through Powershell.

are you able to hook me up with a string to help me out?

Our AD name is: VRIT

i now want to show all groups that belongs to VRIT. we dont want the users, only GROUPS.!

br

L k.

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Rich Matheisen 48,026 Reputation points
    2023-04-27T14:40:42.4666667+00:00

    Assuming you're looking only for groups that are direct members of the target group (and not members of groups that are direct member of the target group), this should get you started:

    Get-ADGroup groupx -property member |
        ForEach-Object{
            $x = Get-ADObject $_.distinguishedName
            if ($x.objectClass -eq 'group'){
                $x.name
            }
        }
    
    
    0 comments No comments

  2. Limitless Technology 45,051 Reputation points
    2023-04-28T14:44:23.3466667+00:00

    Hello,

    With this script you can get and export the group memberships to an AD Group:

    Get-ADGroupMember -Identity <groupname> | Select-Object name, objectClass,distinguishedName | Export-CSV -Path “adgroupmembers.csv”

    --If the reply is helpful, please Upvote and Accept as answer--

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.