I love the new PowerShell 3.0 Active Directory commands.  I find that I rarely need to use 3rd party cmdlets anymore.

Today I was tasked with pulling group membership from a specific group in Active Directory and exporting specific data on each group member to a CSV file.  Here’s the script I wrote.  Change the two variables at the beginning to match your needs.

$groupname = ‘YourADGroupName’
$filepath = ‘C:\Directory\filename.csv’
Get-ADGroupMember -Identity $groupname | Select-Object samaccountname | %{Get-ADUser $_.samaccountname -Properties mail, displayName} | Select-Object SamAccountName, GivenName, Surname, Enabled, Mail, displayName, DistinguishedName |Sort-Object SamAccountName | Export-Csv -Path $filepath -NoTypeInformation