This script creates a CSV file listing the below details for all Active Directory users. The script could be very easily extended to include any extra user properties.
sAMAccountName
displayName
description
TerminalServicesProfilePath
TerminalServicesHomeDirectory
TerminalServicesHomeDrive
ProfilePath
HomeDirectory
HomeDrive
scriptPath
msNPAllowDialin
' --------------------------------------------------------------------------------- ' List Properties of All AD Users ' ' Author: Phil Eddies ' https://geekshangout.com ' ' Disclainer: ' Use of this script / software is entirely at your own risk no support, warranty ' or guaranty is given. ' ' The author or GeeksHangout.com take not responsibility for any damage or problems ' caused by this script / software. ' ' Copyright 2008 Philip Eddies ' ' Licensed under GPL ' This program is free software: you can redistribute it and/or modify ' it under the terms of the GNU General Public License as published by ' the Free Software Foundation, either version 3 of the License, or ' (at your option) any later version.' ' ' This program is distributed in the hope that it will be useful, ' but WITHOUT ANY WARRANTY; without even the implied warranty of ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ' GNU General Public License for more details.' ' ' You should have received a copy of the GNU General Public License ' along with this program. If not, see <http://www.gnu.org/licenses/>. ' ' --------------------------------------------------------------------------------- Set objRootDSE = GetObject("LDAP://RootDSE") strDNSDomain = objRootDSE.Get("defaultNamingContext") set objConn = CreateObject("ADODB.Connection") set objCmd = CreateObject("ADODB.Command") objConn.Provider = "ADsDSOObject" objConn.Open "Active Directory Provider" Set objCmd.ActiveConnection = objConn objCmd.Properties("Cache Results") = False strFilter = "(&(objectclass=user)(objectcategory=person))" strQuery = "<LDAP://" & strDNSDomain & ">;" & strFilter & ";distinguishedName;subtree" objCmd.CommandText = strQuery Set wshFSO=Createobject("Scripting.FileSystemObject") Const ForReading = 1 Const ForWriting = 2 Const ForAppending = 8 strCSVPath = "C:\Users_Details.csv" if wshFSO.FileExists(sUsersLeft) then wshFSO.deletefile(sUsersLeft) end if Set objLogFile = wshFSO.CreateTextFile(strCSVPath) objLogFile.Write("SAM Name, Display Name, Description, TS Profile Dir, TS Home Dir, TS Home Drive Letter, Profile Dir, Home Dir, Home Drive Letter, Logon Script, Allowed Dial In" & chr(13) & chr(10)) Set objRecordSet = objCmd.Execute Do Until objRecordSet.EOF strDN = objRecordSet.Fields("distinguishedName") Set objUser = GetObject("LDAP://" & strDN) strsAMAccountName = objUser.sAMAccountName strsdisplayName = objUser.displayName strDescription = objUser.description strTerminalServicesProfileDirectory = objUser.TerminalServicesProfilePath strTerminalServicesHomeDirectory = objUser.TerminalServicesHomeDirectory strTerminalServicesHomeDriveLetter = objUser.TerminalServicesHomeDrive strProfileDirectory = objUser.ProfilePath strHomeDirectory = objUser.HomeDirectory strHomeDriveLetter = objUser.HomeDrive strScriptPath = objUser.scriptPath strAllowedDialIn = objUser.msNPAllowDialin objLogFile.Write(strsAMAccountName & ", " & strsdisplayName & ", " & strDescription & ", " & strTerminalServicesProfileDirectory & ", " & strTerminalServicesHomeDirectory & ", " & strTerminalServicesHomeDriveLetter & ", " & strProfileDirectory & ", " & strHomeDirectory & ", "& strHomeDriveLetter & ", "& strscriptPath & ", "& strAllowedDialIn & chr(13) & chr(10)) objRecordSet.MoveNext Loop msgbox "Complete." & vbLF & "Ouput has been saved to " & strCSVPath objLogFile.close objConn.Close Set objGroup = Nothing Set objRootDSE = Nothing Set objCmd = Nothing Set objConn = Nothing