Get AD Nested Group Members with Powershell

Use the following script to get nested AD group members using powershell.

Import-Module ActiveDirectory

function Get-ADNestedGroupMembers {
  [cmdletbinding()]
  param ( [String] $Group )            
  Import-Module ActiveDirectory
  $Members = Get-ADGroupMember -Identity $Group -Recursive | select samaccountname | %{Get-ADUser $_.samaccountname -Properties mail}
  $members
}

Get-ADNestedGroupMembers "GROUP" | Select Name,SamAccountName,mail,enabled

Leave a Reply

Your email address will not be published. Required fields are marked *