Avatar of PtboGiser
PtboGiser
Flag for Canada asked on

Quick way to Audit AD OU for users that are a members of a specified group

I have an OU containing a couple hundred users that are all to be removed from the default 'Domain Users' group upon account creation and placed in a custom primary group.  Occasionally another staff may forget to do this, so I'd like a quick an easy way to audit that OU and discover any users in it that are still memebers of Domain Users.

I have this where the search base is the OU in question:
Get-ADUser -filter {memberof -recursivematch "CN=Domain Users,OU=Users,DC=<domain>,DC=<domain>"} -SearchBase "OU=<ou>,OU=<ou>,OU=<ou>,DC=<domain>,DC=<domain>"

But it returns no results, even if there are users in the specified OU that are members of Domain Users.

Can somone correct my powershell script?  Or maybe advise a way I can do this from the Active Directory Users and Computers GUI?  Thanks!
Active DirectoryWindows Server 2008

Avatar of undefined
Last Comment
PtboGiser

8/22/2022 - Mon
Venugopal N

dsget group "CN=Domain Users,OU=users,DC=Contoso,DC=Com" -members

Which will list the user memberof the domain users group.
SOLUTION
dave_it

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Mike Kline

Glad we were able to help out.

Thanks

Mike
PtboGiser

ASKER
-See my final comment for the final Powershell commands I used
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck