Home

Black Mountain

My Experiment on the Internet

Quest PowerShell extensions GET-QADGroupMember

Last year, I found a neat tool to list group members in PowerShell. Well, my co-worker asked me about it again and it's a good thing I blog as I couldn't remember what I told him.

Turns out, Get-QADGroupMember was the tool I was after. This time there was a slight twist. He wants to get the members of a distribution group that are nested in another one and weed out any duplicates.

Hmmm...... Probably not the prettiest way, but this seems to get us the information he needs. It will error if there are user accounts in the top level group.

# Requires Quest Active Directory Extension
# Get date for file name
$day = Get-Date -UFormat "%Y%m%d"

$count = 0
$groups = Get-QADGroupMember "Distribution list name"
foreach ($group in $groups)
  { $count++
    $members = Get-QADGroupMember $group.DisplayName
   }
$members | sort-object | select DisplayName | get-unique -asstring | Export-Csv -Path $day-members.csv

It could be improved by allowing input from the PoSH line. I may update tomorrow.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h3> <blockquote> <img>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

Sometimes I get asked, so here it is ... My Amazon.com Wish List

Thought I'd see what this Technorati stuff does.

Login with your OpenID to leave comments
contents copyright Steven Peck - powered by drupal logo