AD Group Enumeration

Welcome Forums General PowerShell Q&A AD Group Enumeration

Viewing 1 reply thread
  • Author
    • #51988
      Topics: 1
      Replies: 0
      Points: 0
      Rank: Member

      I am trying the code below to get adgroup from a Specific OU and all Nested group in that Group and with output shows only
      Group Name and Nested Group Name , I can get the Group Name but can someone help to get the output for Nested Group Name ?

      $Groups = Get-ADGroup -Properties * -Filter * -SearchBase "OU=Security Groups,DC=local,DC=company,DC=org"

      $Table = @()

      $Record = [ordered]@{
      "Group Name" = ""
      "Name" = ""
      "Username" = ""

      Foreach ($Group in $Groups)

      $Arrayofmembers = Get-ADGroupMember -recursive -identity $Group | select name,samaccountname

      foreach ($Member in $Arrayofmembers)
      $Record."Group Name" = $Group
      $Record."Name" = $
      $Record."UserName" = $Member.samaccountname
      $objRecord = New-Object PSObject -property $Record
      $Table += $objrecord



      $Table | # export-csv "C:\temp\SecurityGroups.csv" -NoTypeInformation

    • #51992
      Topics: 8
      Replies: 1271
      Points: 1,020
      Helping Hand
      Rank: Community Hero

      If you are looking for a visual representation, there are scripts out there like this one:

      You are not the first person to try to report on nested AD groups, so I would recommend some binging or googling to look at some working solutions.

Viewing 1 reply thread
  • The topic ‘AD Group Enumeration’ is closed to new replies.