locked
How to list group AD group members then list attributes of those members RRS feed

  • Question

  • Hello,

    Below is a script where I want to list the members of an Active Directory Group, then I want to pipe that to the Get-Aduser cmdlet to list a property.  How do I do this?  I get errors regarding the Identity with the code below.  I also would like to pipe this all to a file so I can use later.  Thanks in advance for the help.

    PS C:\> get-adgroupmember "techadmin" -recursive | select-object name | get-aduser -Identity $_ -Properties Employeeid

    Monday, April 4, 2011 6:52 PM

Answers

  • get-adgroupmember "techadmin" -recursive | % {
    	$group=$_
    	get-aduser $_ -Properties Employeeid | select @{n="Group";e={$group}},Name,SurName,GivenName,Employeeid 
    }
    • Marked as answer by SdeDot Monday, April 4, 2011 8:58 PM
    Monday, April 4, 2011 7:26 PM

All replies

  • get-adgroupmember "techadmin" -recursive | get-aduser  -Properties Employeeid
    Monday, April 4, 2011 7:01 PM
  • Thanks Kazun

    So this seems to list out all Properties for the object, not just EmployeeID.

    In an output file, I would like to list in col. 1 the group member name, then in col 2., col 3, I would like to list properties.  So in col 1, I would list the member name, then for example in col. 2 I would list the Surname, in col. 3 in Givenname, etc.

    Monday, April 4, 2011 7:11 PM
  • get-adgroupmember "techadmin" -recursive | % {
    	$group=$_
    	get-aduser $_ -Properties Employeeid | select @{n="Group";e={$group}},Name,SurName,GivenName,Employeeid 
    }
    • Marked as answer by SdeDot Monday, April 4, 2011 8:58 PM
    Monday, April 4, 2011 7:26 PM
  • Thanks Kazun!
    Monday, April 4, 2011 8:58 PM
  • Hi Kazun,

    How can I get members of multiple AD Group.

    I mean may be I will lots of groups from this

    Get-ADGroup -Filter{GroupCategory -eq "Security" -and Name -like "Tech*"}

    then I have to loop through your PowerShell which will give the members of those groups.

    get-adgroupmember "techadmin" -recursive | % {
    $group=$_
    get-aduser $_ -Properties Employeeid | select @{n="Group";e={$group}},Name,SurName,GivenName,Employeeid
    }

    Thank you

    Sri

    Tuesday, May 7, 2013 7:41 PM
  • Hi Kazun,

    How can I get members of multiple AD Group.

    I mean may be I will lots of groups from this

    Get-ADGroup -Filter{GroupCategory -eq "Security" -and Name -like "Tech*"}

    then I have to loop through your PowerShell which will give the members of those groups.

    get-adgroupmember "techadmin" -recursive | % {
    $group=$_
    get-aduser $_ -Properties Employeeid | select @{n="Group";e={$group}},Name,SurName,GivenName,Employeeid
    }

    Thank you

    Sri


    North, you may want to start a new thread, as this is a thread that has been marked as answered, and you have a new question

    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.

    Tuesday, May 7, 2013 7:55 PM
  • I realize this is an old thread, but this may be useful to others looking as well...I believe it should achieve the same in a simpler form:

    Get-ADGroupMember techadmin -Recursive | Get-ADUser -Properties * | Select-Object cn, surname,
     givenname, employeeid, enabled, co | Export-Csv C:\yyyymmdd_membersoftechadmin.csv

    additional fields like enabled and co were included as examples of useful fields for a report like this

    at the end of the command, the file name is an example that may be modified.    The file name is what's after the c:\

    a different path may also be used

    Friday, September 16, 2016 10:45 PM
  • I realize this is an old thread, but this may be useful to others looking as well...I believe it should achieve the same in a simpler form:

    Get-ADGroupMember techadmin -Recursive | Get-ADUser -Properties * | Select-Object cn, surname,
     givenname, employeeid, enabled, co | Export-Csv C:\yyyymmdd_membersoftechadmin.csv

    additional fields like enabled and co were included as examples of useful fields for a report like this

    at the end of the command, the file name is an example that may be modified.    The file name is what's after the c:\

    a different path may also be used


    You have not included the groupname which is the point of the exercize.

    \_(ツ)_/

    Friday, September 16, 2016 11:15 PM
  • I realize this is an old thread, but this may be useful to others looking as well...I believe it should achieve the same in a simpler form:

    Get-ADGroupMember techadmin -Recursive | Get-ADUser -Properties * | Select-Object cn, surname,
     givenname, employeeid, enabled, co | Export-Csv C:\yyyymmdd_membersoftechadmin.csv

    additional fields like enabled and co were included as examples of useful fields for a report like this

    at the end of the command, the file name is an example that may be modified.    The file name is what's after the c:\

    a different path may also be used


    You have not included the groupname which is the point of the exercize.

    \_(ツ)_/

    The groupname is techadmin.  He did include it.  He just piped things through a little cleaner.  Many ways to do the same job.  I used it just fine to find display name and phone number for members of a group.  Thanks to all!
    Monday, November 12, 2018 7:34 PM