Ryk
Ryk

Reputation: 3102

POWERSHELL: List all users/members in a specific AD OU Group

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

Answers (3)

Fabian Sanchez
Fabian Sanchez

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

user2569317
user2569317

Reputation: 1

I just did this:

get-qadgroupmember -identity "group name"

Upvotes: 0

x0n
x0n

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

Related Questions