Adding other fields not available to Get-ADGroupMember

This topic contains 4 replies, has 3 voices, and was last updated by  Andre 2 weeks, 4 days ago.

  • Author
    Posts
  • #78905

    Andre
    Participant

    I am currently using the following command:

    Get-ADGroupMember -Identity "ISE-EEFF-SDA-STANDARD" | Select Name,SamAccountName,DistinguishedName | Export-CSV -Path ISE-EEFF-SDA-STANDARD.csv -NoTypeInformation

    I am wanting to expand it so that I also get first (givenName), and last names (SN). How would I go about doing this?

  • #78907

    Kevyn
    Participant

    You can do a custom attribute for them.

    $ADGrpMems = Get-ADGroupMember -Identity ISE-EEFF-SDA-STANDARD
    $ADGrpMems | Select-Object -Property Name,SamAccountName,DistinguishedName,@{Name = "FirstName";Expression = {(Get-ADUser $_.DistinguishedName).GivenName}},@{Name = "LastName";Expression = {(Get-ADUser $_.DistinguishedName).SurName}} | Export-CSV -Path ISE-EEFF-SDA-STANDARD.csv -NoTypeInformation
    
  • #78910

    Kevyn
    Participant

    Updated the above code to include the export to CSV.

  • #78959

    David Schmidtberger
    Participant

    why not just pipe from get-adgroupmember straight to get-aduser.

    Get-ADGroupMember -Identity "ISE-EEFF-SDA-STANDARD" |get-aduser -prop givenname,surname|select name,give
    nname,surname,samaccountname,Distinguishedname| Export-CSV -Path ISE-EEFF-SDA-STANDARD.csv -NoTypeInformation
    
  • #78986

    Andre
    Participant

    Many thanks, I went with the 2nd option and it worked like a treat.

You must be logged in to reply to this topic.