Powershell - group members & attribs for multiple groups report?

This topic contains 3 replies, has 4 voices, and was last updated by Profile photo of Adnan Rashid Adnan Rashid 2 years, 4 months ago.

  • Author
    Posts
  • #17467
    Profile photo of Jake Sully
    Jake Sully
    Participant

    Hello,

    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?

    TY!
    Jake

  • #17469
    Profile photo of Daniel Krebs
    Daniel Krebs
    Participant

    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.

    Regards,
    Daniel

  • #17472
    Profile photo of Rob Simmers
    Rob Simmers
    Participant

    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
  • #17641
    Profile photo of Adnan Rashid
    Adnan Rashid
    Participant

    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

You must be logged in to reply to this topic.