title: How can I get group members from an AD group that only contains security groups?
body: <p>I have 3 groups (HR, COMPT and FIN) and their groups contains only security groups.
  How do I extract their members of their groups?</p>
  <pre><code>$Groups = 
  @&quot;
  GroupNames;
  HR
  COMPT
  FIN
  &quot;@ | ConvertFrom-Csv -Delimiter ';'
  
  #HR has 3 security groups
  #COMPT has 5 security groups
  #FIN has 2 security groups
  ### I want to know how can I get their members ###
  
  foreach ($Group in $Groups){
  #Save-File to this Path
  $Path = &quot;C:\Temp\&quot;
  
  $group.GroupNames | Get-ADGroupMember | select name -ExpandProperty Name | ForEach-Object { 
  Get-ADGroup $_ -Properties Members | select Name |
  #Export CSV
  Export-Csv -Path (Join-Path -Path $path -ChildPath ('{0}.csv' -f $group.Name)) -NoTypeInformation -Delimiter &quot;;&quot; -Encoding UTF8
  
    }
  }
  </code></pre>