Step 1: Install the Active Directory Module
To connect and query an AD group with PowerShell, the Active Directory module needs to be loaded. You can do it by installing RSAT tools installed. Please refer to this post to check the Active Directory module status:
How to check if you have Active Directory module installed
Step 2: Use Get-AdGroupMember to list members
For example, this PowerShell command: Get-ADGroupMember -identity “All Employees” will list all members of “All Employees”
You can also export the results with the member name using this command:
For example, Get-ADGroupMember -identity “All Employees” | select name
Step 3: Export group members to CSV file
you can export the group member list to csv using this PowerShell command:
Get-ADGroupMember -identity “group name” | select name | Export-csv -path c:\it\filename.csv -Notypeinformation
For example,
Get-ADGroupMember -identity “All Employees” | select name | Export-csv -path c:\temp\allemployees.csv -Notypeinformation