# AD group members to CSV

Exporting Active Directory (AD) group members to a CSV file is a practical task for system administrators who need to manage and audit user access or membership. Here, we'll guide you through a straightforward process using PowerShell to export AD group members to a CSV file.

**Open PowerShell with Administrative Privileges**

Press `Windows + X` and select “Windows PowerShell (Admin)” from the menu.

**Import the Active Directory Module**

Before executing any AD commands, you must import the Active Directory module with the following command:

```powershell
Import-Module ActiveDirectory
```

This command loads the cmdlets necessary for AD operations.

**Identify the AD Group Name**

Know the exact name of the AD group whose members you want to export. For this example, let’s assume the group name is “FinanceTeam”.

**Execute the Command to Export Group Members to CSV**

Use the following PowerShell command, replacing “FinanceTeam” with the name of your group:

```powershell
Get-ADGroupMember -identity "FinanceTeam" | Select-Object name,samaccountname | Export-Csv -path "C:\AD_GroupMembers.csv" -NoTypeInformation
```

* `Get-ADGroupMember`: This cmdlet gets the members of an AD group.
    
* `-identity "FinanceTeam"`: Specifies the group name.
    
* `Select-Object name,samaccountname`: Selects the columns to export. Here we’re choosing the name and samaccountname, but you can customize this based on the information you need.
    
* `Export-Csv`: This cmdlet exports the information to a CSV file.
    
* `-path "C:\AD_GroupMembers.csv"`: Specifies the output file path and name.
    
* `-NoTypeInformation`: Excludes the type information from the CSV file.
    

Check the Exported CSV File: Navigate to the path where you exported the CSV file (`C:\AD_GroupMembers.csv` in this example) and open it with your preferred spreadsheet program to review the list of AD group members.

**Additional Tips:**

* Ensure that your user account has the necessary permissions to perform these operations.
    
* You can customize the `Select-Object` part of the command to include more or different attributes as per your requirement, such as email address, department, etc.
    

This guide offers a basic approach to exporting AD group members to a CSV file.
