Skip to content

Instantly share code, notes, and snippets.

@justincjahn
Last active October 10, 2015 06:47
Show Gist options
  • Select an option

  • Save justincjahn/3649783 to your computer and use it in GitHub Desktop.

Select an option

Save justincjahn/3649783 to your computer and use it in GitHub Desktop.
List Active Directory Users and Groups
Get-ADUser -Filter * -Properties MemberOf | select @{n="Username";e={$_.Name}},@{n="SID";e={$_.SID}},@{n="Security Groups";e={($_.MemberOf | Where-Object {($_ | get-adgroup).GroupCategory -eq "Security"} | Foreach-Object { ($_ | get-adgroup).Name}) -join "; "}},@{n="Distribution Groups";e={($_.MemberOf | Where-Object {($_ | get-adgroup).GroupCategory -eq "Distribution"} | Foreach-Object { ($_ | get-adgroup).Name}) -join "; "}} | Export-Csv -NoTypeInformation C:\Users\jjahn\Documents\users.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment