Powershell - group members & attribs for multiple groups report?


I am trying to find a way to export the members of specific groups that I have display names of in a list. I need user attributes such as display name, email address, description, account creation date, and LastLogon.

I want to then export the data “ideally” per group from the list into a CSV, but if not, then something that would at least put the group name that is queried in a column in the CSV so the list could be sorted easily and the viewer would be able to see the members of each group by scrolling down. One CSV per group would be best.

Can anyone assist?


Hi Jake,

If I were you I would search for examples in the TechNet Script Center (http://gallery.technet.microsoft.com/scriptcenter), this forum, check out http://poshlinks.com or Bing/Google. Exporting AD users and the last logon timestamp is a very common topic with a lot of examples out there.


Take a look at Quest Active Directory cmdlets. While this can be accomplished many ways using Get-AdGroupMember (with RSAT tools installed) or using ADSI, the Quest tools make it a one-liner because the cmdlet returns user data versus just the LDAP path of the member of the group.

Get-QADGroupMember -Identity "Domain Admins" | Select DisplayName, Email, Description, whenCreated, LastLogon | Export-CSV C:\MyReport.csv

I guess you could do this. I think you need to do abit more work with this really if you want to output the group name - perhaps put the details into a hashtable and then output that?

$group = ‘Project_Name’

Get-ADGroupMember -Identity $group | Get-ADUser -Properties name, description, Created, lastlogon, $group | ConvertTo-Csv | out-file C:\Temp\test.csv