Solved

Hot to pull Active Directory users with no group membership

Posted on 2014-03-10
8
393 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
Comment Utility
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
Comment Utility
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
Comment Utility
$contents = get-content "list of the file.txt"
foreach ($obj in $contents)
{
if ((Get-ADPrincipalGroupMembership $obj | ? {$_.name -notlike "domain users"}) -eq $NULL)
{
$OBJ
}
0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
Comment Utility
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
Do email signature updates give you a headache?

Constantly trying to correctly format email signatures? Spending all of your time at every user’s desk to make updates? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today!

 
LVL 8

Expert Comment

by:jpgobert
Comment Utility
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
Comment Utility
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
Comment Utility
This worked ! thank you subsun .
0
 
LVL 14

Expert Comment

by:Justin Yeung
Comment Utility
Missing } at the end
0

Featured Post

Why spend so long doing email signature updates?

Do you spend loads of your time carrying out email signature updates? Not very interesting are they? Don’t let signature updates get you down. Let Exclaimer Cloud - Signatures for Office 365 make managing email signatures a breeze.

Join & Write a Comment

Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now