Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Hot to pull Active Directory users with no group membership

Posted on 2014-03-10
8
Medium Priority
?
404 Views
Last Modified: 2014-03-10
Hi EE

I dont know where to start on this.. I have a list of 100's of SamAccountNames and I need to know which of these accounts do not have any Active Directory groups .. well no other groups but Domain Users.
0
Comment
Question by:MilesLogan
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 8

Expert Comment

by:jpgobert
ID: 39918292
The easiest way will be to run your search for users where memberOf is null (or not present).

I used the Find function in Active Directory Users and Computers, Advanced tab, and added the condition User -> Member Of -> Not Present.  

That gave me a list of all user accounts that have no group memberships beyond Domain Users.
0
 
LVL 2

Author Comment

by:MilesLogan
ID: 39918305
Hi jpgobert .. thanks for the tip but that will not work for me since I only want to check a list of users and these are in all different OUs .
0
 
LVL 14

Expert Comment

by:Justin Yeung
ID: 39918310
$contents = get-content "list of the file.txt"
foreach ($obj in $contents)
{
if ((Get-ADPrincipalGroupMembership $obj | ? {$_.name -notlike "domain users"}) -eq $NULL)
{
$OBJ
}
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 40

Accepted Solution

by:
Subsun earned 2000 total points
ID: 39918314
Input the SamAccountNames names in C:\User.txt, and run the following code.. result will give you the SamAccountName's with no group membership..
GC C:\User.txt | ?{(Get-ADuser $_ | Get-ADPrincipalGroupMembership | ?{$_.Name -ne "Domain Users"}) -eq $null}

Open in new window

0
 
LVL 8

Expert Comment

by:jpgobert
ID: 39918316
I'm looking up the info now for piping your user list from a text file into a powershell command that'll do what you want.  

Are we only dealing with one domain?  

Do you want the output to write to another file?
0
 
LVL 2

Author Comment

by:MilesLogan
ID: 39918346
Hi Justin .. I received the error below on yours ..

+ {
+ ~
Missing closing '}' in statement block.
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : MissingEndCurlyBrace
0
 
LVL 2

Author Closing Comment

by:MilesLogan
ID: 39918348
This worked ! thank you subsun .
0
 
LVL 14

Expert Comment

by:Justin Yeung
ID: 39918355
Missing } at the end
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s time for spooky stories and consuming way too much sugar, including the many treats we’ve whipped for you in the world of tech. Check it out!
In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question