I am new to this forum and a beginner at powershell. In activedirectory, I am trying to retrieve the list of users for a group name starting with say “abc” and would like to only see users with country “India” for a group
I have tried this command so far but country isnt working
My first thought process was to use get-adgroup and filter names with abc and then use get-adgroupmember to get the list of users within that group but i cant filter country which is an ldapfilter in activedirectory
got this error on this one:
get-aduser : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties
do not match any of the parameters that take pipeline input.
can someone direct me the thought process here? I really want to learn. Thank you!
What do you actually expect as result of your query? With the first part of the pipeline you get the desired groups and with the second part you get the groupmembers of all these groups. But you loose the info about the group. And since the groupmember does not have a property country you cannot select it.
I assume you want to have the information about the groupmembers including the information about what group they are member of. Therefor you will need a nested loop.
First you query the desired groups. In the outer loop you iterate over all found groups and query the members of each group. And in the inner loop you query each individual group member for its AD account where you can filter for the ones with the country “India”. There (in the inner loop) you combine everything in a PSCustomObject and you’re done.
I havent used nested loop before. Parden my expertise on powershell. still learning.
I am trying to get a list of all users from a group. There are multiple groups with the same name in it. Example - ‘Companyabc’, ‘Company2abc’ etc. Within these groups we have users. We have a mix of users from different countries. I only would like users from India within those groups.