\nbut didn’t work …<\/p>\n<\/blockquote>\n<\/aside>\n
Can you elaborate?<\/p>\n
I assume you mean the group does not show up? \nYou can use a calculated property to do this. \n(see my sample below)<\/p>\n
foreach ($group in $groups) {\n \n Get-ADGroupMember $group | Get-ADUser -Properties samaccountname, userprincipalname |\n Select-Object @{n='GroupName';e={$group}},samaccountname, userprincipalname\n}\n<\/code><\/pre>\n<\/blockquote>\n<\/aside>\nOMG i was doing it right … i just missed the brackets around the expression … damn …<\/p>\n
thank you anyway …<\/p>","upvoteCount":1,"datePublished":"2020-04-02T16:23:22.000Z","url":"https://community.spiceworks.com/t/get-adgroupmember-select-group/757633/3","author":{"@type":"Person","name":"oumolayna","url":"https://community.spiceworks.com/u/oumolayna"}},{"@type":"Answer","text":"
<\/p>\n
Glad you got it resolved!<\/p>","upvoteCount":0,"datePublished":"2020-04-02T16:41:34.000Z","url":"https://community.spiceworks.com/t/get-adgroupmember-select-group/757633/4","author":{"@type":"Person","name":"homer-t-nacho-cheese","url":"https://community.spiceworks.com/u/homer-t-nacho-cheese"}},{"@type":"Answer","text":"
Nealy beat me to it…<\/p>","upvoteCount":0,"datePublished":"2020-04-02T18:51:31.000Z","url":"https://community.spiceworks.com/t/get-adgroupmember-select-group/757633/5","author":{"@type":"Person","name":"DoctorDNS","url":"https://community.spiceworks.com/u/DoctorDNS"}}]}}
oumolayna
(oumolayna)
April 2, 2020, 4:12pm
1
hey people , im trying to get the members of three groups , select SamAccountName,UserPrincipalName and the name of the group it belongs to , i’ve reached this far
$groups = "grp1", "grp2","grp3"
#Write-Output $groups
foreach ($group in $groups) {
Get-ADGroupMember $group | Get-ADUser -Properties samaccountname, userprincipalname |
Select-Object samaccountname, userprincipalname
}
i tried adding
,$group
but didn’t work … i tried adding a hash
@{n="group";e="$group"}
also not the results i want …
how can i achieve that? i would like the name of the group to appear next to each user
@thomaslee
6 Spice ups
Neally
(Neally)
April 2, 2020, 4:14pm
2
oumolayna:
but didn’t work …
Can you elaborate?
I assume you mean the group does not show up?
You can use a calculated property to do this.
(see my sample below)
foreach ($group in $groups) {
Get-ADGroupMember $group | Get-ADUser -Properties samaccountname, userprincipalname |
Select-Object @{n='GroupName';e={$group}},samaccountname, userprincipalname
}
1 Spice up
oumolayna
(oumolayna)
April 2, 2020, 4:23pm
3
Neally:
oumolayna:
but didn’t work …
Can you elaborate?
I assume you mean the group does not show up?
You can use a calculated property to do this.
(see my sample below)
foreach ($group in $groups) {
Get-ADGroupMember $group | Get-ADUser -Properties samaccountname, userprincipalname |
Select-Object @{n='GroupName';e={$group}},samaccountname, userprincipalname
}
OMG i was doing it right … i just missed the brackets around the expression … damn …
thank you anyway …
1 Spice up
Glad you got it resolved!
DoctorDNS
(DoctorDNS)
April 2, 2020, 6:51pm
5