One-liner to get all the members of an AD group

With this line you get all the users of an Active Directory group recursively, so any nested group is expanded. It is also exported to a CSV file.

[code lang=“powershell” light=“true”]Get-ADGroupMember -Identity ‘GroupName’ -Recursive | Get-ADUser -Properties ‘*’ | Select-Object samAccountName, name, givenName, sn, mail, l | Export-Csv -Encoding UTF8 -Delimiter ‘;’ -path ‘.users.csv’[/code]