PowerShell - Export Group Members to CSV

16. October 2011 16:52

This script will export a .CSV for each group in an OU.  The CSV will be named the same as the group name.

Get-Group -OrganizationalUnit "Some OU" | ForEach-Object { Get-Group -Identity $_.Name | ForEach { $_.Members } | Get-User | Export-Csv ($_.Name + '.csv') }

Remember this script is designed to run on one line.  Remove the linebreaks.

About Jim Bouse

I grew up with computers being a part of my life.  I set up my first 'network' by 15 (in 1997) and have been exploring innovative ways to make the lives easier for everyday people using tools readibly available.

 

I now work for Texas A&M University as a Senior Systems Administrator designing and maintaining a GIS system that is used by thousands of users daily.