header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Pipe get-qaduser to get-qadmemberof
Last Post 07 Jul 2011 11:12 PM by gdf1903. 2 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
gdf1903User is Offline
New Member
New Member
Posts:15
Avatar

--
06 Jul 2011 08:36 AM
    Hi,

    Hopefully someone can point me in the right direction. I'm trying to query AD for all users and the groups that user is a member of, and export the data to a CSV file.

    I can export the users:

    $FilePath = "output.csv"
    $OuDomain = "DC=DOMAIN, DC=local"
    Get-QADUser -searchRoot $OuDomain -SizeLimit 0 `
    | select-Object dn, sAMAccountName ` | Export-Csv $FilePath

    How would I add a get-qadmemberof to this? I tried placing it after the select-object but get an error.

    Thanks.
    JonathanUser is Offline
    Basic Member
    Basic Member
    Posts:109
    Avatar

    --
    06 Jul 2011 10:25 AM
    I am not sure this is the exact format you want, and it will be difficult to get this readable in a CSV file, but try this...

    Get-QADUser -searchRoot $OuDomain -SizeLimit 0 | Select-Object dn, sAMAccountName, @{Name="Groups";Expression={(Get-QADMemberOf $_ | Select-Object -expandProperty Name) -join ";"}} | export-csv $FilePath

    This will concatenate all your group names separated by ";".
    Jonathan Tyler
    http://powershellreflections.wordpress.com
    Follow Me On Twitter
    gdf1903User is Offline
    New Member
    New Member
    Posts:15
    Avatar

    --
    07 Jul 2011 11:12 PM
    Thanks a lot Jonathan, pretty much exactly what I wanted. Much appreciated!
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer