PowerShell: ADMemebers of multiple ADGroups

So you need to provide a list of AD groups and the AD members of those groups. The AD group names all start with FIN_.

Our friends over at Quest have written a great PowerShell snapin that can help us with this. The Snapin is Quest.ActiveRoles.ADManagement.

You can download it here: http://www.quest.com/powershell/activeroles-server.aspx

Here is the code that will give you the output you need:

foreach($adgroup in get-qadgroup|where-object{$_.name -match "FIN_"}) {get-qadgroupmember $adgroup.name | Format-Table -property $adgroup.name, name}

We are using a foreach loop so that we can run through all the groups and then pull the members. Main reason we do it this way is because we need to maintain the groupname for the output in the table.

So we stick the groupname in $adgroup, we match the groups with the where-object{$_.name -match "FIN_" command. Now that we have the groups, we use the $adgroup.name to pull the members.

There might be a better, shorter, and, or, more efficient way to do this, but this works perfect.

Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

  • RT @Bob41Dylan: Today in 1969 the first eposide of "The Johnny Cash Show" aired! It had an impressive start with Bob Dylan as first guest.… 1 week ago
  • RT @tommleach: Steven Hawking was born on the date Galileo died, and he died on the date Einstein was born. Sometimes the chaos of the univ… 3 months ago
  • RT @tedlieu: Hmmm, is this a coincidence or did Trump confidant Carl Icahn have insider information? twitter.com/JuddLegum/stat… 3 months ago
  • RT @F1: - Never miss a second of the action - Ride onboard with the entire grid - Re-live history with archive footage access F1 TV is co… 3 months ago
  • @F1 It is about time. I can’t wait for F1 TV, and the pricing looks very reasonable. 3 months ago
%d bloggers like this: