Created
June 13, 2016 22:28
-
-
Save matt40k/7ded896bf9fc14bc21602ceebf6be7dd to your computer and use it in GitHub Desktop.
M (PowerQuery) query for querying members of AD Groups
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let | |
Source = ActiveDirectory.Domains("domain.com"), | |
#"euser eroot eadidom com" = Source{[Domain="domain.com"]}[Object Categories], | |
group1 = #"euser eroot eadidom com"{[Category="group"]}[Objects], | |
#"Expanded securityPrincipal" = Table.ExpandRecordColumn(group1, "securityPrincipal", {"sAMAccountName"}, {"securityPrincipal.sAMAccountName"}), | |
#"Filtered Rows" = Table.SelectRows(#"Expanded securityPrincipal", each Text.StartsWith([securityPrincipal.sAMAccountName], "GROUPNAME")), | |
#"Expanded group" = Table.ExpandRecordColumn(#"Filtered Rows", "group", {"member"}, {"group.member"}), | |
#"Expanded group.member" = Table.ExpandListColumn(#"Expanded group", "group.member"), | |
#"Expanded user" = Table.ExpandRecordColumn(#"Expanded group.member", "group.member", {"mail"}, {"Email Address"}), | |
#"Filtered Rows1" = Table.SelectRows(#"Expanded user", each [Email Address] <> null), | |
#"Renamed Columns" = Table.RenameColumns(#"Filtered Rows1",{{"securityPrincipal.sAMAccountName", "Security Group"}}), | |
#"Removed Other Columns" = Table.SelectColumns(#"Renamed Columns",{"Email Address", "Security Group"}) | |
in | |
#"Removed Other Columns" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment