How to load the AD Group which is a member of another AD Group in PowerShell? RRS feed

  • Question

  • I am actually working on creating a GUI to manage the members of AD Groups and sometimes it is possible that a group could also be a member of another group. I am able to load members of the group however how can I load the group in the member list. I have created a shell script. I heard about the foreign security principle and has been following the topic to learn that but finding it hard to understand it.

    Here's my script that takes the group name as argument and loads the members attribute of the group:

    $SamAccountName = Get-ADObject -Filter { CN -eq $GroupName } -Properties SamAccountName | Select -ExpandProperty SamAccountName
    #Getting Members of the Group
    Get-ADGroupMember -Identity $SamAccountName | where {$_.objectclass -eq 'user'} | 
    Get-ADUser -Properties displayname, ObjectGUID | 
    Select displayname, ObjectGUID | Sort-Object displayname
    Any suggestion is highly appreciated.

    • Edited by Nikul Vyas Monday, June 24, 2019 4:05 PM Question Edited
    Monday, June 24, 2019 4:05 PM

All replies