none
Get-ADGroupMember + User Managers Name

    Question

  • Hi,

    Can someone please help me list users in a specific AD security group with their Managers Name?


    Many thanks.

    Monday, February 20, 2012 3:05 PM

Answers

  • $dn = Get-ADGroupMember -Identity Administrators | select -ExpandProperty distinguishedname 
    $users = $dn | Get-ADObject | ? {$_.objectclass -eq 'user'}
    $users | Get-ADUser -Properties manager | select name, manager


    Grant Ward, a.k.a. Bigteddy

    What's new in Powershell 3.0 (Technet Wiki)

    • Marked as answer by Jo Gaffney Monday, February 20, 2012 3:41 PM
    Monday, February 20, 2012 3:17 PM
  • Get-ADGroupMember DNGROUP | Get-ADUser -Properties manager -ea silentlycontinue | Select Name,Manager


    • Edited by KazunMVP Monday, February 20, 2012 3:20 PM
    • Marked as answer by Jo Gaffney Monday, February 20, 2012 3:41 PM
    Monday, February 20, 2012 3:19 PM

All replies

  • $dn = Get-ADGroupMember -Identity Administrators | select -ExpandProperty distinguishedname 
    $users = $dn | Get-ADObject | ? {$_.objectclass -eq 'user'}
    $users | Get-ADUser -Properties manager | select name, manager


    Grant Ward, a.k.a. Bigteddy

    What's new in Powershell 3.0 (Technet Wiki)

    • Marked as answer by Jo Gaffney Monday, February 20, 2012 3:41 PM
    Monday, February 20, 2012 3:17 PM
  • Get-ADGroupMember DNGROUP | Get-ADUser -Properties manager -ea silentlycontinue | Select Name,Manager


    • Edited by KazunMVP Monday, February 20, 2012 3:20 PM
    • Marked as answer by Jo Gaffney Monday, February 20, 2012 3:41 PM
    Monday, February 20, 2012 3:19 PM

  • That works perfect, thanks alot Bigteddy.

    Is there a way to list the additional security groups that the users are members of and then list them in separate columns in a csv as well as their manager?

    Thanks.

    Monday, February 20, 2012 3:36 PM
  • Thanks Kazun. Can i possibly export a list of the users that are in the original security group and include the manager and additional groups that they are a member of?

    I hope that makes sense!


    Thanks.

    Monday, February 20, 2012 3:43 PM
  • Get-ADGroupMember DNGROUP | Get-ADUser -Properties manager,memberof -ea 0 | Select Name,Manager,
    	@{n="MemberOf";e={($_.memberof |Get-ADGroup | Where {$_.GroupCategory -eq 'Security'}) -join ";"}} |
    		Export-Csv C:\result.csv -NoType

    • Proposed as answer by Bigteddy Monday, February 20, 2012 4:48 PM
    Monday, February 20, 2012 3:48 PM
  • Kazun, thanks again.

    Because the "MembersOf" output is all on one line, i cant really filter out users that are in additional matching groups that easily. Is there any way that i can run the "Get-ADGroupMember" command for two specific groups? ie. Get-ADGroupMember DNGROUP1 & DNGROUP2.

    Monday, February 20, 2012 3:59 PM
  • I don't understand your question.  Can you please explain what you mean?

    Grant Ward, a.k.a. Bigteddy

    What's new in Powershell 3.0 (Technet Wiki)

    Monday, February 20, 2012 4:47 PM
  • I've managed to get alot further than earlier so thanks for your help so far.

    My issue now is that i need to run a command to display users that are in two specific groups. ie. Get-ADGroupMember DNGROUP1 & DNGROUP2.

    Can you possibly help with that?

    Monday, February 20, 2012 4:53 PM
  • I suggest you start a new thread, as that seems to be a different (although similar) question.

    Grant Ward, a.k.a. Bigteddy

    What's new in Powershell 3.0 (Technet Wiki)

    Monday, February 20, 2012 4:59 PM