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.

Commenting on this Blog entry is closed.

Tags: