none
get-content groups.txt | foreach {Get-QADGroupMember $_}

    Question

  •  

    get-content groups.txt | foreach {Get-QADGroupMember $_}

    Name                           Type            DN
    ----                               User           <dn>
    x                     
    y                                   User          <dn>

     

    I need the group name where is user has resided.

    Help required.

    Monday, April 26, 2010 10:20 AM

Answers

  • Hi,

    I think he needs the following format:

    Name                  Type            DN          Group
    ----                              
    x  User           <dn>       group list                      
    y                        User            <dn>        group list

    Try this

    $users=get-content users.txt

    write-host "Name                  Type            DN          Group "

    Foreach($user in $users)
    {

    $group=get-Qadmemberof $user
    $user=Get-qaduser $user

    write-host $user.name, "user", $group

    }


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Wednesday, April 28, 2010 10:26 AM
    Moderator

All replies

  • If you're wanting a history of the membership of that group, that isn't retained in AD.  Yoiu'll need to enable auditing and get that from the security event logs.
    Monday, April 26, 2010 12:56 PM
  • Can you clarify your request?
    Shay Levy [MVP]
    http://blogs.microsoft.co.il/blogs/ScriptFanatic
    PowerShell Toolbar
    Monday, April 26, 2010 5:51 PM
    Moderator
  • Hi,

    I think he needs the following format:

    Name                  Type            DN          Group
    ----                              
    x  User           <dn>       group list                      
    y                        User            <dn>        group list

    Try this

    $users=get-content users.txt

    write-host "Name                  Type            DN          Group "

    Foreach($user in $users)
    {

    $group=get-Qadmemberof $user
    $user=Get-qaduser $user

    write-host $user.name, "user", $group

    }


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Wednesday, April 28, 2010 10:26 AM
    Moderator