• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 843
  • Last Modified:

Script to find all enabled users accounts inside AD doamin

Hello Dears,

I need a  scrip to find all enabled user accounts located in an Active directory domain.

Could someone help please ?

Thanks In advance!
0
Suliman Abu Kharroub
Asked:
Suliman Abu Kharroub
1 Solution
 
Krzysztof PytkoActive Directory EngineerCommented:
type it in command-line on server or workstation with Administrative Tools installed

dsquery user -name * -limit 0| dsget user -fn -ln -samid -email -desc -disabled >c:\users.txt

Import text file into excel and filter it for "no" in disabled column.
0
 
JhonnylaCommented:
Hello,

I use powershell for querying AD and the quest activeroles management shell.  free download from:
http://www.quest.com/powershell/activeroles-server.aspx
Then you get AD specific commandlets.
the one below should give you all enabled users:
Get-QADUser -Enabled -SizeLimit 0
0
 
Mike KlineCommented:
both methods given are good

I like using a great tool called adfind by Joe Richards

http://www.joeware.net/freetools/tools/adfind/index.htm

adfind -default -bit -f  "&(objectcategory=person)(objectclass=user)(!userAccountControl:AND:=2)" samaccountname displayname -csv > c:\EnabledUsers.csv

if you want disabled just run the same query but remove the ! before useraccountcontrol

That will give you a csv file on your C drive with all enabled users.

Thanks
Mike
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Suliman Abu KharroubIT Consultant Author Commented:
Thanks all, sorry for the late reply. I was on vacation.

i will test and post back here.
0
 
Suliman Abu KharroubIT Consultant Author Commented:
Thanks again.

@iSiek:
"dsget failed:Directory object not found" returned error.

the text file shows result but it is not complete.

@Jhonnyla: It give a correct info, but the result is shown all in a single column event when i run  :Get-QADUser -Enabled -SizeLimit 0 >c:\test.csv

can i export the result on excel file in three columns?

@mkline71:

"ldap_get_next_page_s: [DC-FQDN] Error 0x57 (87) - Filter Error" returned error
0
 
Suliman Abu KharroubIT Consultant Author Commented:
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now