Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Active Directory Query Question - Query Only Enabled Users

Posted on 2016-08-29
10
Medium Priority
?
181 Views
Last Modified: 2016-08-29
I am looking to find a way to be able to to either DSGET, DSQUERY a list of all of the enabled users in a particular OU. More specifically, if you are looking at my screenshot, I need a query of all of the enabled users in the 1575 OU and the disabled users to be excluded.
2016-08-29-09_32_48-NEWSECGXDC---Rem.png
0
Comment
Question by:Jonathan DiVincenzo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 16

Accepted Solution

by:
FOX earned 2000 total points
ID: 41774758
Use powershell, right-click run as administrator
1st command     Import-Module ActiveDirectory
2nd command    Get-ADuser -filter "Enabled -eq 'True'" -searchbase "Ou=ouname,ou=ouname,dc=domain,dc-com" | ft samaccountname, DisplayName | out-file c:\temp\Enabledusers.csv


**To get the path to the OU in question Make sure your view in ActiveDirectory users and computers  has Advance Features checked and User, contacts, groups and computers as containters checked.
Right-click the OU in question, click properties, click the attribute tab, sroll down to distinguishedName, highlight it and click view then do a ctrl c for your copy and then paste after -searchbase in the command above. Make sure the OU path is in quotes " "
0
 

Author Comment

by:Jonathan DiVincenzo
ID: 41774918
Thanks Foxluv,

The commands provided did populate an entire list of all the Enabled users in our domain, but what I need for my client is a concentrated automated list of just the enabled users in 1575 Users OU.
0
 
LVL 16

Expert Comment

by:FOX
ID: 41774927
Did you read the bottom part of my instructions?  Get the OU from the distinguished name and put it in the -searchbase part of the command
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:Jonathan DiVincenzo
ID: 41774934
Ok wow, that was honestly not there when I was looking at that a little bit ago. But since I just reloaded the page, the bottom part appeared. I'll give it a try and see what happens. Thanks!
0
 

Author Comment

by:Jonathan DiVincenzo
ID: 41774965
Awesome, that looks great! Just one little problem. Even though the Display Name perimeter is filled out in AD, the final csv output does not display the Display Name. Any idea what that's all about? See screenshot if needed.
2016-08-29-11_44_29-Microsoft-Excel-.png
0
 
LVL 16

Assisted Solution

by:FOX
FOX earned 2000 total points
ID: 41774971
Try this one, make sure you add in your OU again.

Get-ADuser -filter "Enabled -eq 'True'" -searchbase "Ou=ouname,ou=ouname,dc=domain,dc-com" | ft samaccountname,GivenName,Surname,DisplayName | out-file c:\temp\Enabledusers.csv
0
 

Author Comment

by:Jonathan DiVincenzo
ID: 41775081
Foxluv, you definitely get to take the cake in this one! Thanks a lot!
0
 
LVL 16

Expert Comment

by:FOX
ID: 41775083
Good work
0
 

Author Closing Comment

by:Jonathan DiVincenzo
ID: 41775084
For whatever reason, Display Name was not working so I removed that value from my command. Otherwise, perfect solution!
0
 
LVL 16

Expert Comment

by:FOX
ID: 41775230
Jon,
Sorry about the displayname.  If you need it try this.  (put in your OU again)

Get-ADuser -properties * -filter "Enabled -eq 'True'" -searchbase "Ou=ouname,ou=ouname,dc=domain,dc-com" | ft samaccountname,GivenName,Surname,DisplayName | out-file c:\temp\Enabledusers.csv
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Active Directory can easily get cluttered with unused service, user and computer accounts. In this article, I will show you the way I like to implement ADCleanup..
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!
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses

610 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