Score:0

Have List of user but I want to find out if they are added to specific ADGroupMember

ec flag

I have been trying to understand how to import my csv file and export of specific adgroup they are added or even they are not added

Import-CSV " C:\Users\user.csv" | ForEach-Object { Get-ADGroupMember $_. sAMAcountName -Properties * |Select sAMAcountName } |Export-CSV "c:\Users\userswithgroup.csv"

I dont really understand why its not working what went wrong.

Score:3
us flag

I think your main issue is that you're using Get-ADGroupMember rather than what you need which is Get-ADPrincipalGroupMembership

You use Get-ADGroupMember to query a group and find out who is a member of it, but in your case you're passing a username to it not a group name, so it won't find anything. So you'd want something like :

Import-CSV " C:\Users\user.csv" | ForEach-Object { Get-ADPrincipalGroupMember $_.sAMAcountName |Select Name }

which should then return the group memberships of each of the users listed in the .csv file, assuming that's appropriately formatted.

K0n2113 avatar
ec flag
Thank you very much! it helps!
LeeM avatar
cn flag
If it helps, please accept as the answer to your question.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.