none
Need to export users from multiple AD groups RRS feed

  • Question

  • HELLO..

    I need to export list of users from multiple AD groups ( Around 170) in a single csv file. Please let me know if this can be possible.

    Any help is appreciated.

    Thanks

    RIWA


    RIWA

    Thursday, September 10, 2015 3:06 PM

Answers


  • $groups | % { get-ADgroup $_.groupname | get-ADgroupMember } | export-csv $path 


    remember to import ActiveDirectory module, and to import-csv file with list of group names with header groupname to var $groups. Try to make it on Your own, in other case You'd never learn how to script / use PS. Hint: to get users from nested groups use -recursive.

    Good Luck

    • Marked as answer by RIWAA Tuesday, September 15, 2015 3:00 PM
    Thursday, September 10, 2015 8:33 PM

All replies

  • Hi,

    Yes, this is possible.

    Prewritten scripts can be found in the repository here:

    https://gallery.technet.microsoft.com/scriptcenter

    If you'd like to take a crack at this yourself, look at Get-ADGroupMember:

    http://ss64.com/ps/get-adgroupmember.html

    Let us know if you have any specific questions. If you do, please post your code (using the 'Insert Code Block' button of the input editor) and your errors.


    Thursday, September 10, 2015 3:10 PM

  • $groups | % { get-ADgroup $_.groupname | get-ADgroupMember } | export-csv $path 


    remember to import ActiveDirectory module, and to import-csv file with list of group names with header groupname to var $groups. Try to make it on Your own, in other case You'd never learn how to script / use PS. Hint: to get users from nested groups use -recursive.

    Good Luck

    • Marked as answer by RIWAA Tuesday, September 15, 2015 3:00 PM
    Thursday, September 10, 2015 8:33 PM
  • Above command is to pull info from one group.. what if I need grou membership for multiple groups.

    RIWA

    Tuesday, September 15, 2015 3:04 PM
  • Above command is to pull info from one group.. what if I need grou membership for multiple groups.

    RIWA

    That command will work for as many groups as you specify. You just need to import your file properly.

    Tuesday, September 15, 2015 4:55 PM