$allgroups=get-adgroups $t = foreach ($g in $allgroups) { $m = get-adgroupmember $g foreach ( $me in $m ) { $me | add-member -membertype noteproperty -name "groupname1" -value $g.name -force } $m | select } $t | select *groupname, name | export-csv -path ExportedGroupMembers.csv
Links