Link to home
Start Free TrialLog in
Avatar of Suliman Abu Kharroub
Suliman Abu KharroubFlag for Jordan

asked on

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!
Avatar of Krzysztof Pytko
Krzysztof Pytko
Flag of Poland image

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.
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
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
Avatar of Suliman Abu Kharroub

ASKER

Thanks all, sorry for the late reply. I was on vacation.

i will test and post back here.
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
ASKER CERTIFIED SOLUTION
Avatar of Suliman Abu Kharroub
Suliman Abu Kharroub
Flag of Jordan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial