Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
This guide is a hands-on step by step showing how to write a Powershell script to Get AD Group Members. The final script is included at the end of the guide.
What You Need to Write a Powershell Script to Get AD Group Members
To build this script you will need the following:
- Basic knowledge of PowerShell commands
- A PowerShell script Editor (PowerShell ISE or PowerGUI)
- The name of the AD group you want to export its members
Powershell Script to Get AD Group Members (Basic Commands)
In this demo, I will export members of the group shown in the image below:

Follow the steps below to build the Powershell Script to Get AD Group Members:
- Open your script editor. I will be using PowerGUI. Then open a new scripting window. Save the file as Export-ADGroupMembers

The first step is to determine the PowerShell cmdlets we need. The easiest way to find a PowerShell command is to use the Get-Command cmdlet.
Popular on Amazon
- Bulk Flash Drives: 20 pack 2GB USB flash drives with 20 lanyards. MECHEER USB memory stick with flexible storage and color options! Perfect for business needs, events, giveaways, or personal use. These versatile storage solutions work great whether you're handling corporate projects, or just organizing your digital life.
- Durable & Portable: This pocket-sized USB flash drive(2.27" x 0.75") travels effortlessly with you. USB thumb drive featuring a 360-degree metal swivel cap that safeguards the USB port, mini USB pen drive rugged aluminum casing withstands daily wear & tear. The jump drive is equipped with a detachable lanyard and easily attach to your key chain or bags to avoid from losing and for easy carrying.
- Zero-Setup Convenience: Plug and play flash drive pack, no need to install any software - even your grandma can use it. USB drives can instantly works on any device - just plug in and start transferring files. Thumbdrive universal compatibility with windows: XP, Vista, 7, 8, 10 & 11. USB 2.0 flash drive backwardly compatible with 1.1 ports, perfect for older laptops and car stereos.
- FAT Format: The default file system for 2GB USB flash drives is FAT, providing read/write compatibility with both Windows and macOS. This format is ideal for storing music, photos, videos, software installers and general document files. Pro Tip: Maximize performance by reformatting to your optimal file system.(FAT32: Universal compatibility (files under 4GB); exFAT: Cross-platform large file support; NTFS: Advanced Windows features (encryption/compression))
- LED Indicator: The end of the USB flash drive is designed with an indicator. The LED indicator lights up when you plug the memoria USB storage drive into the devices, the light blinks while write/read activities are in process. In this case, do not remove the backup drive. Otherwise, data integrity and the service life of the USB sticks are affected.
The beauty of Powershell is that the commands are descriptive. So to find a command that exports (gets AD members), run the command below:
Get-Command -Name *GroupMember
Here is the result of the command:

The command we are looking for is Get-ADGroupMember
- The next step is to determine how to use this command. To do this we will run the command below:
Get-Help Get-ADGroupMember
Here is the result

Looking at the syntax, I can see a parameter called [-Identity] <ADGroup>. It means that if I know the name of the group I can use the command below to lists its members:
Get-ADGroupMember -Identity "Windows Admins"
The result in PowerShell:

You would have thought that the result will give us exactly what we need. Unfortunately, it returned more than one property of an AD User. It requires more work.
Also popular on Amazon
- 10 Pack USB Sticks: 10 pieces of USB flash drives are fit for a variety of scenarios. Whether the flash drives USB are used as school supplies for high school students to backup data storaged in USB jump drives or music USB flash drive for car, zip drive can meet the basic storage needs. USB drive pack of 10 has a higher cost performance. USB flash drive pack of 10 is suitable for ordinary users with appropriate needs, but also for special groups such as companies, schools or other organizations that need a large number of U disks. In short, thumb drives can meet the needs of different customers.
- Swivel Design: With the 360° swivel design, all the ports of the thumb drives 10 pack can be hidden inside the metal casing. When needed, simply swivel the casing gently and the ports will automatically expose, making it convenient for you to insert and remove. This design is not only fashionable and beautiful but also more user-friendly, whether you'd like your flash drive for photos, flash drive for video storage, or memory sticks for computers. In addition, the swivel design can effectively protect the interface from damage and pollution, increasing the service life of the flash USB drive.
- Portability: The small hole on the thumbdrive USB is designed for lanyards, which is convenient to carry. Besides, the USB flash drive keychain can also be tied through the small hole to prevent loss. This design is very thoughtful and reflects the humanized design concept of the memorias USB flash drive.
- Plug and Play: You can use the computer storage flash drive immediately for data storage or backup without any additional installation after inserting it into the computer. This plug and play feature makes the laptop storage drive a very convenient external ssd. You can copy the required data files to the external drive at any time without worrying about computer system compatibility issues. In addition, the design of the external flash drive enables it to be quickly recognized by the system after being inserted into the computer. (NOTE: Please check if your device has a USB-A port before purchasing. If not, a USB-C hub is needed.)
- FAT32 format: The default system format for 8GB flash drive is FAT32. FAT32 USB flash drive is widely applicable, such as in televisions, DVD players, vehicles, printers, embroidery machines, etc. Be patient if you have problems with system recognition. It may take some time for initial recognition, but it will happen.
Before we proceed, we will update our script. Copy the command Get-ADGroupMember -Identity “Windows Admins” into your script editor.
The updated Powershell script to get AD Group members is shown below:

- Next step is to add the command to a variable, I will call the variable $Members. The updated PowerShell script to get AD group members will now look like this:

The next section takes the script to the next level!
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesPowershell Script to Get AD Group Members (Advanced)
In this section I will build on what I have done so far. Here is what we have so far.
Also popular on Amazon
- 【128MB Flash Drives 50 Pack】Our thumb drives 128MB with 50 lanyards, and 10 different color choices making it easy to categorize the other files for storage.
- 【Store and Protect Data】 Go through a rigorous quality control process, the USB 2.0 flash drive 128MB has a mature appearance and stable high-standard storage technology, which helps us to protect our data from loss.
- 【Plug and Play】No need to install any software, the bulk flash drives support Windows/Linux/Mac OS, and are compatible with USB 2.0 and below. Plug it into a USB port and works fast. The read speed is 15-25mbp/s,and the write speed is about 8-12mbp/s.
- 【Easy to Carry】The frosted and metal cover can prevent fingerprints, The USB drive 50 pack has a hole design to hang it on a lanyard or key chain, compact size(2.2*0.8*0.4in) is easy to carry.
- 【Widely Used】Widely used in schools, businesses, photography, media, and so on. 128MB thumb drive bulk can be used as a present for birthdays/teacher's day/children's day/various conferences and exhibitions.

Look at the result closely. Each user has the following properties: distinguishedName, name, objectClass, objectGUID, SamAccountName and SID. But I just need the users name and Login Name (SamAccountName).
I will modify the script to display only these two properties. Here is the updated PowerShell script to get AD group members script.


This looks good but we can make the output look more user friendly. I will like the script to replace “name” with “Full Name” and “SamAccountName” with “User Name”.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Here is the updated Powershell script to get AD group members:
Also popular on Amazon
- 【What You Get】 20 pieces 2 GB small capicity bulk usb flash drives,which allow you to classify your files, music, pictures etc. Great choice for enhancing your Name's visibility as the pen drives can be printed on


The output is looking just the way I want it! In the next section I will add one last bit to the script.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Powershell Script to Get AD Group Members (Export Result to CSV)
To complete the script I want to add the last bit: a command that will export the output to CSV. I will simply pip the output into the Export-CSV command.
Here is the final script

And the CSV output

You can copy the script below:
$Members = Get-ADGroupMember -Identity "Windows Admins"
$Members | Select-Object @{Name="Full Name";Expression={$_.name}},`@{Name="User Name";Expression={$_.SamAccountName}} |`
Export-CSV -NoTypeInformation -Path C:\PS\Export-ADGroupMembers\CSV-Report.csv
Hope you see how easy it is to write a PowerShell to get ad group members. The aim of the guide is to walk you through how I write a typical PowerShell script.
I believe it benefits you more to learn how to write a PowerShell script instead of just copying a script.
Also popular on Amazon
- The durable, light-weight design of the Turbo Attaché 3 USB 3.0 Flash Drive is the essential mobile storage solution
- Perfect for transferring large files such as movies, videos, photos, music & documents
- Transfer speeds up to 10 times faster than standard USB 2.0 flash drives
- Convenient sliding collar, and cap-less design protects your content when not in use
- Compatible with most PC and Mac laptop and desktop computers with USB 3.0 ports
I hope you found this script helpful. If you did, kindly spare 2 minutes to share your experience with our community at [discourse_topic_url].
However, if you have any questions regarding this article or if the steps did not fix your problem, please post your question at [discourse_topic_url]. Our team and other community members will come back to you with a fix as soon as possible.
Lastly, to learn more about PowerShell, visit our PowerShell Page.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Quick Recap
Other Helpful Guides
- PowerShell Array and Add to Array: Applications and Examples
- Powershell NoTypeInformation: Applications and Examples
Additional Resources and References
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

