Hi, I need some help from you experts to search AD for users that have a username that contains more than 4 characters and export this to excel. This is what I have now:
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "User Name"
objExcel.Cells(1, 2).Value = "Full Name"
objExcel.Cells(1, 3).Value = "Description"
strDomain = InputBox ("Enter Domain Name")
Set DomObj = GetObject("WinNT://" & strDomain )
DomObj.Filter = Array("User")
For Each objUser In DomObj
objExcel.Cells(intRow, 1).Value = objUser.Name
objExcel.Cells(intRow, 2).Value = objUser.FullName
objExcel.Cells(intRow, 3).Value = objUser.Description
intRow = intRow + 1
Next
objExcel.Range("A1:C1").Select
objExcel.Selection.Interior.ColorIndex = 19
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Cells.EntireColumn.AutoFit
MsgBox "Done
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "User Name"
objExcel.Cells(1, 2).Value = "Full Name"
objExcel.Cells(1, 3).Value = "Description"
strDomain = InputBox ("Enter Domain Name")
Set DomObj = GetObject("WinNT://" & strDomain )
DomObj.Filter = Array("User")
For Each objUser In DomObj
objExcel.Cells(intRow, 1).Value = objUser.Name
objExcel.Cells(intRow, 2).Value = objUser.FullName
objExcel.Cells(intRow, 3).Value = objUser.Description
intRow = intRow + 1
Next
objExcel.Range("A1:C1").Select
objExcel.Selection.Interior.ColorIndex = 19
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Cells.EntireColumn.AutoFit
MsgBox "Done