ObjCommand.Properties("Page Size") = 1000 "' WHERE objectClass='user' AND objectCategory='person'" "FROM 'LDAP://" & objRootDSE.Get("defaultNamingContext") & _ ObjCommand.CommandText = "SELECT sAMAccountName, userAccountControl, givenName, sn, mail, company " & _ Set objRootDSE = GetObject("//RootDSE">LDAP://RootDSE") ObjCommand.ActiveConnection = objConnection Set objCommand = CreateObject("ADODB.Command") ObjConnection.Open "Active Directory Provider" Set objConnection = CreateObject("ADODB.Connection") ObjFile.WriteLine "AD Username,First Name,Last Name,E-mail,Company" Set objFile = objFileSystem.OpenTextFile(REPORT_FILE, 2, True, 0) Set objFileSystem = CreateObject("Scripting.FileSystemObject") ' Generate an excel csv file with user.csv file name.ĭim objFileSystem, objFile, objConnection, objCommand, objRootDSE, objRecordSetĭim strUsername, strFirstname, strLastname, strEmail, strCompany This list will then be exported to Microsoft Excel as comma separated value (CSV) file. If you know Visual Basic Scripting (VBS), you can pull out any report from any Active Directory object really easy.Īs shown below, this VB Script will generate a list of information about the user Username, First Name, Last Name and Email Address.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |