This VBS Script will send all of the NT or Active Directory (AD) domain user names to excel.
VBS Script:
strDomain = InputBox ("Enter Domain Name Or Machine Name")
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "Domain Name"
objExcel.Cells(1, 2).Value = "User Name"
Set colAccounts = GetObject("WinNT://" & strDomain & "")
colAccounts.Filter = Array("user")
For Each objUser In colAccounts
objExcel.Cells(intRow, 1).Value = UCase(strDomain)
objExcel.Cells(intRow, 2).Value = objUser.Name
intRow = intRow + 1
Next
objExcel.Range("A1:B1").Select
objExcel.Selection.Interior.ColorIndex = 19
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Cells.EntireColumn.AutoFit
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
Set objRange = objExcel.Range("B1")
objRange.Sort objRange,1,,,,,,1
MsgBox "Done"
No Comments