Query on Group membership

Hi Everyone,

Looking for a script to export list of AD users who are member of “Group A” but not member of “Group B”. Could you please assist ?




Yes, you will have to use Get-ADUser with Where-Object cmdlet. You can follow below docs to understand more about those cmdlets.

Get-ADUser: https://docs.microsoft.com/en-us/powershell/module/activedirectory/get-aduser?view=winserver2012-ps
Where-Object: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/where-object?view=powershell-5.1

Let us know when you get stuck…