Link to home
Start Free TrialLog in
Avatar of Kelly Garcia
Kelly GarciaFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Check if users are in group - powershell

Hi guys,

I have a list of users and a list of groups and I need to check if those users are in the group, so far I have written this script, please can someone help me complete it:


$m=Get-QADGroup "*pae*admin*" | Get-QADGroupMember

$p=Get-QADGroup "*pae*"

I need to check if the users in $m exist in the groups in $p

thank you in advance.
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

1. "*pae*admin*"  
2. "*pae*"

will always return true as all members of 1 are members of 2  pae*admin* is a member of pae*
ASKER CERTIFIED SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Kelly Garcia

ASKER

HI,

Is there anyone that can help me with this? I know its something simple, but I just can figure it out.

Regards,
kay
You'll have to clarify your intentions because the example you proposed in the beginning suffers from the group name confusion.

The most efficient way to check if a user exists in two groups is to write an LDAP query that only returns those results. However, it can't be a wild-card based search.

If you must use wild-cards you can't overlap them (as David has pointed out), it doesn't make sense to do so.

Is the example in the first instance accurate?

Chris