Vbscript / Active Directory / Enumerate Ad Users
This script retrieves all user objects in an OU and assigns variables to some basic properties. Insert any operation you require instead of the Wscript.Echo line.
strOU = "Users" strDomain = "dc=domain,dc=local"
Set objOU = GetObject("LDAP://ou=" & strOU & "," & strDomain)
objOU.Filter = Array("user")
For Each objUser in objOU
userName = objUser.SAMAccountName userDisplay = objUser.cn userHome = objUser.HomeDirectory userProfile = objUser.Profile
Wscript.Echo userName & " - " & userHome
Next
Set objOU = Nothing Set objUser = Nothing
Please note that a disclaimer applies to any code on this page.
|