← script library
Effortlessly Export Active Directory Group Members with PowerShell
Active DirectoryDecember 24, 2024
In this post, we will introduce a PowerShell script that simplifies the process of exporting members of a specific Active Directory group. Managing group memberships is crucial for ensuring proper access control and compliance within your organization. This script allows administrators to quickly extract the list of users from a designated group and export it to a CSV file for easy review and reporting. Here is the PowerShell script for exporting Active Directory group members:
powershell
# Import the Active Directory module
Import-Module ActiveDirectory
# Define the group name and output file
$groupName = "YourADGroup" # Replace with your actual group name
$outputFile = "C:\Reports\GroupMembers.csv" # Path to save the report
# Retrieve group members
$groupMembers = Get-ADGroupMember -Identity $groupName | Select-Object Name, SamAccountName, UserPrincipalName
# Export the members to a CSV file
$groupMembers | Export-Csv -Path $outputFile -NoTypeInformation
Write-Host "Group members for '$groupName' have been exported to $outputFile successfully."Run it across your fleet
This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.
More in Active Directory
Active Directory User Onboarding with PowerShell
2026-08-17Active Directory User Offboarding with PowerShell
2026-08-17Disable an Active Directory User with PowerShell
2026-08-17Enable an Active Directory User with PowerShell
2026-08-17Unlock an Active Directory Account with PowerShell
2026-08-17Reset an Active Directory Password with PowerShell
2026-08-17Ready when you are.
Try ServerEngine free for 7 days.