Get list of Active directory groups and members

$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  

About Jeff Turner

Technical director of Nano Tera Network Solutions.
This entry was posted in Powershell, VBS, VBA and other scripting., System Administration. Bookmark the permalink.