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 Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,174 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Rich Matheisen 42,906 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 43,231 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