Configure the ReFS volume before or after installing Exchange Server 2013/2016/2019. It's important to configure…
We have security groups in Active Directory User and Computers (ADUC). In these security groups, we have users and security groups. If you have security groups in a security group, we call them nested security groups. How to list all users and security groups in a security group through PowerShell? Find out in this article how to list the content through PowerShell.
Get a list of users and security groups
We have a security group with the name SG_Office. We like to list all the users and security groups in that security group. Run PowerShell as administrator. We are going to make use of the Get-ADGroupMember cmdlet.
PS C:\> Get-ADGroupMember -Identity "SG_Office" | Select-Object Name | Sort-Object Name Name ---- Benetiz Anees Larson Tevin SG_Administration SG_Amsterdam SG_Communication SG_Field SG_Finance SG_HR SG_London SG_Madrid SG_Paris SG_Production SG_Recruiting SG_Sales
If you want to confirm. Go to ADUC and open the security group SG_Office. Click Members. The same list of users and security groups will show. You can see that we have two users and more then a couple of security groups.
Now that we have the users and security groups, what if we want to list the users in the nested security groups?
Get a list of users and users in nested security groups
We want to get all the users and the users in the nested security groups in the security group SG_Office. Let’s sort the list on Display Name.
PS C:\> Get-ADGroupMember -Identity "SG_Office" -Recursive | Get-ADUser -Property DisplayName | Select-Object DisplayName | Sort-Object DisplayName DisplayName ----------- Adams Forrest Albert Corrie Beltran Noah Benetiz Anees Boyce Caoimhe Boyce Julie Chester Braiden Curtis Cari Foley Clifford Hodgson Leela Jones Weronika Klein Menna Larson Tevin Lopez Rebeca Mack Johanna Mcghee Kayne Mckinney Vanessa Monroe Cara Pitts Karina Todd Jake Wilson Herman Woodley Reya
There you have it, all the users in the security group SG_Office.
In this article, you learned how to list all users in a security group through PowerShell. Did you enjoy this article? You may also like the article Add users to group with PowerShell. Don’t forget to follow us and share this article.