Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 409
  • Last Modified:

Hot to pull Active Directory users with no group membership

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
MilesLogan
Asked:
MilesLogan
  • 3
  • 2
  • 2
  • +1
1 Solution
 
jpgobertCommented:
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
 
MilesLoganAuthor Commented:
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
 
Justin YeungSenior Systems EngineerCommented:
$contents = get-content "list of the file.txt"
foreach ($obj in $contents)
{
if ((Get-ADPrincipalGroupMembership $obj | ? {$_.name -notlike "domain users"}) -eq $NULL)
{
$OBJ
}
0
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

 
SubsunCommented:
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
 
jpgobertCommented:
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
 
MilesLoganAuthor Commented:
Hi Justin .. I received the error below on yours ..

+ {
+ ~
Missing closing '}' in statement block.
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : MissingEndCurlyBrace
0
 
MilesLoganAuthor Commented:
This worked ! thank you subsun .
0
 
Justin YeungSenior Systems EngineerCommented:
Missing } at the end
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Building an Effective Phishing Protection Program

Join Director of Product Management Todd OBoyle on April 26th as he covers the key elements of a phishing protection program. Whether you’re an old hat at phishing education or considering starting a program -- we'll discuss critical components that should be in any program.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now