Quicktip: Export Group Membership via Powershell

This scripts pulls a list of groups from a CSV and exports all memberships to a new CSV file based off of the group name. Each group gets its own file. This is useful if you plan on making major changes to group membership and want a safety net.

$Deletes=import-csv d:\Groups\groupstodelete.csv
foreach ($GGroup in $deletes){
$GetGroup=get-qadgroup $GroupName
"samaccountname"|out-file -append d:\groups\exports\$Groupname.csv
if ($Getgroup.allmembers){
foreach ($GUser in $GetGroup.allmembers){
$GADUser=get-qaduser $Guser
$GADUser.samaccountname|out-file -append d:\groups\exports\$Groupname.csv

Script requires the AD Powershell modules & the Quest AD Management Powershell modules to be installed


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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s