logo logo

Script to return total number of enabled users in Active Directory

This script ran from a command prompt will present you a text file which can be opened in Excel that will list all ENABLED active directory users. Useful for quoting licenses.

dsquery * -filter "(&(sAMAccountType=805306368)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))" -limit 0 | dsget user -display -email -dept -title > C:\ActiveUsers.txt
ECHO Results saved to C:\ActiveUsers.txt