hi friends,
i am not good in powershell and i need a help
in our active directory there are a lot of users which are a members in Groups,

i need to list the users which are just members in these groups together grp1 and grp2

Example:
(user1 is member in domain users group, grp1 )
(user2 is a member in domain users group, grp1 and grp2)
in the output of the script i have to see just the user2
because user2 is member f grp1 and grp2 together
can you help with a script please

8 Spice ups

How far have you come. Even if you only have one or 2 lines of code just post it using the <> code button. It’ll look better. Like this it gives some the feeling they are doing your homework. Don’t feel shy if the code is full of bugs. We all had to start from zero and we too made horrible mistakes and we too got facepalmed for it.
We’re here to help and guide but it’s not fun to write complete solutions for others. That way you also won’t learn from it :wink:

5 Spice ups

Post your current code, please. We’ll help you build on to it.

4 Spice ups

Cpuld you not export the list from within AD the use a filter in excel?

OP read this and try. Do not forget to import the active directory module in powershell first or the commands won’t be recognised.

https://ss64.com/ps/get-adgroup.html
If you don’t have it available check up on rsat and the active directory PowerShell module.

so you have n number of groups, but you want to know which users are member of two specific groups?
no matter if they are member of more than these two groups?

if so you can get all AD-Users (get-help Get-ADUser -detailed),
get the members of the groups (get-help Get-AdGroupMember -detailed) and write into a variable,
loop through all the users with foreach-loop and check if the user is in both groups and if so, output the user or write it in an array.

This sounds like a homework question.

What do you have so far OP?

3 Spice ups