locked
PS script to export all security groups members RRS feed

  • Question

  • Hi There,

    I am brand new to powershell and am in need of a ps script that will create a list of all members in all our security groups in our OU and then export the results to an excel spreadsheet. 

    What is the best way to do this? I am curious to see what people come up with.

    Thanks!

    Friday, July 14, 2017 4:05 PM

All replies

  • You can find pre-written scripts here: http://gallery.technet.microsoft.com

    Note that you are asking for others to write scripts for you.  That is not the purpose of this forum.

    See this to set your expectations: This forum is for scripting questions rather than script requests


    \_(ツ)_/


    • Edited by jrv Friday, July 14, 2017 4:32 PM
    Friday, July 14, 2017 4:30 PM
  • Hi bstevensoncbc

    You could refer to the following script:

    Get-ADGroup -Filter * | ?{$_.groupcategory -eq 'security'} | select -ExpandProperty name | Get-ADGroupMember | select name | Export-Csv C:\members.csv -NoTypeInformation -Append

    Best Regards,

    Candy


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, July 17, 2017 8:29 AM
  • If the user count is above 5000 in a AD group, you might have to tweak the powershell to get the extract.


    Thanks HA

    Monday, July 17, 2017 9:03 AM
  • Hi bstevensoncbc

    Just checking in to see if the information provided was helpful.

    Please let us know if you would like further assistance.

    Best Regards,

    Candy


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Tuesday, July 18, 2017 8:42 AM
  • Hi bstevensoncbc

    You could refer to the following script:

    Get-ADGroup -Filter * | ?{$_.groupcategory -eq 'security'} | select -ExpandProperty name | Get-ADGroupMember | select name | Export-Csv C:\members.csv -NoTypeInformation -Append

    Best Regards,

    Candy


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    This example is useless.. Just bunch of names without information where they come from.  

    Also, u could filter security adgroups before pipeline.

    Tuesday, July 18, 2017 10:00 AM