This VBS script will Send All Disabled And Locked Out Accounts To Excel
VBS Script:
strComputer = InputBox ("Enter Server Name")
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "Logon Name"
objExcel.Cells(1, 2).Value = "Full Name"
objExcel.Cells(1, 3).Value = "Description"
objExcel.Cells(1, 4).Value = "Domain"
objExcel.Cells(1, 5).Value = "Account Status"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_UserAccount Where Disabled = 'True' Or Lockout = 'True'")
On Error Resume Next
For Each objItem in colItems
objExcel.Cells(intRow, 1).Value = objItem.Name
objExcel.Cells(intRow, 2).Value = objItem.FullName
objExcel.Cells(intRow, 3).Value = objItem.Description
objExcel.Cells(intRow, 4).Value = objItem.Domain
If objItem.Disabled = True Then
objExcel.Cells(intRow, 5).Value = "Disabled"
objExcel.Cells(intRow, 5).Font.ColorIndex = 5
End If
If objItem.Lockout = True Then
objExcel.Cells(intRow, 5).Value = "Locked Out"
objExcel.Cells(intRow, 5).Font.ColorIndex = 3
intRow = intRow + 1
Next
objExcel.Range("A1:E1").Select
objExcel.Selection.Interior.ColorIndex = 19
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Cells.EntireColumn.AutoFit
MsgBox "Done"
No Comments