Overview

Returns an array of accounts within a domain security group.  Does not require the Active Directory module or RSAT, only requires .NET 3.5 or later.

We use a plural noun to allow this function to coincide with the Get-ADGroupMember cmdlet.

Dependencies

Instructions

The PS1 file here contains a function.  You can either add this function to a profile or module of your own, copy and paste the code to your current session, or dot source it like this: ."\\path\to\Get-ADGroupMembers.ps1".

Once the function is available, use it as desired:

PowerShell
Edit|Remove
#dot source the script (or add to your profile or a custom module):  
    . "\\path\to\Get-ADGroupMembers.ps1" 
 
#Get help on Get-ADGroupMembers 
    Get-Help Get-ADGroupMembers -Full 
 
#Get all group members in Domain Admins or nested subgroups, only include samaccountname property 
    Get-ADGroupMembers "Domain Admins" | Select-Object -ExpandProperty samaccountname 
 
#Get members for objects returned by Get-ADGroupMembers to see what we can work with.   
    Get-ADGroupMembers -group "Domain Admins" | Get-Member 
 
#Alternatively, return the first result so we can see example property values returned 
    Get-ADGroupMembers -group "Domain Admins" | Select -First 1 -Property *

Example output: