AD Group Enumeration

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Rob Simmers Rob Simmers 1 month ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #51988
    Profile photo of Athar Saeed
    Athar Saeed
    Participant

    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" = $Member.name
    $Record."UserName" = $Member.samaccountname
    $objRecord = New-Object PSObject -property $Record
    $Table += $objrecord

    }

    }

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

    #51992
    Profile photo of Rob Simmers
    Rob Simmers
    Participant

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

    https://gallery.technet.microsoft.com/scriptcenter/Get-nested-group-15f725f2

    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 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.