Export a list of members from an Active Directory group to a file

Here is a good command line in case you will have need to export members of from security group in Active Directory to a text file for whatever reason it may be on Microsoft Windows Server 2012 R2.

So here is the command line where I want to export all members of ENGINEERING group in Active Directory to a text file:

dsquery group -name “ENGINEERING” | dsget group -members > C:\memberlist.txt

Once the command completes, you should find a memberlist.txt file under C:\> 🙂

also can be used PowerShell:

Get-ADGroupMember -identity “ENGINEERING” | select name | Export-csv -path C:\Output\Groupmembers.csv -NoTypeInformation