Reputation: 3102
I am trying to list the users/group members of a specific AD group in Powershell. I dont want to list everyone and everything, just the group members that I am interested in.
For example: I have a AD group called SqlAdmins. I just want to list the members/users in that group.
I tried this: " Get-QADGroup -sizeLimit 0 | select @{name="GroupName";expression={$_.name}} -expand members | select GroupName,@{n='Member';e={ (Get-QADObject $_).name}}
" and it listed absolutely everything, but cannot work out how to list for only one group.
Thanks a lot.
Upvotes: 2
Views: 55424
Reputation: 11
Here is some simple code that will help to query and export the list:
Get-ADGroupMember "nameofthegroup" -recursive | Select-Object SamAccountName | export-csv c:/nameofthefile.csv
Now I need to know if is possible to exclude people based on another AD Security Group
Upvotes: 1
Reputation: 52480
IIRC, it's a simple as:
get-qadgroup sqladmins | get-qadmemberof
i.e. get the AD group sqladmins, forward it to the next command which will enumerate all members.
As a general guideline for the Quest AD Cmdlets, if you end up writing something as complicated as you did just there for what must seem like a simple task, you're probably doing it wrong ;) Their AD cmdlets are truely excellent.
Upvotes: 3