Simple Script to Dump the members of many groups named similarly

param([Parameter(Mandatory=$true)]$GroupPrefix)
# Just specify the group prefix and the script will query all groups and create a csv file named with the prefix in the temp folder.

# This has a dependancy on Quest Powershell tools
add-pssnapin Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue

# get the data
Get-QADGroup -Name "$GroupPrefix*" | foreach {$group = $_; Get-QADGroupMember -Identity $_ } | Get-QADUser | foreach {New-Object PSObject -Property @{Group=$group.Name; GroupDesc=$group.Description; SamAccountName=$_.SamAccountName;LastName=$_.LastName;FirstName=$_.FirstName;Email=$_.email;DisplayName=$_.DisplayName;Department=$_.Department; DN=$_.DN; Manager=$_.Manager}} | Export-Csv c:\TEMP\$GroupPrefix.csv

$temp = $null
$temp = Import-Csv c:\TEMP\$GroupPrefix.csv