I have been working with an NT4 migration recently and we have been disabling most of the accounts, but needed to know how many accounts that are open.
So I wrote this simple script that views the information in an formated excel file.
Nice and easy!
' Script to view all accounts that are not disabled in an NT4 domain
' You need Excel on your computer
Set objDomain = GetObject("WinNT://your domain name,domain")
objDomain.Filter = Array("User")
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "Username"
objExcel.Cells(1, 1).Font.Bold = True
objExcel.Cells(1, 1).Interior.ColorIndex = 30
objExcel.Cells(1, 1).Font.ColorIndex = 2
objExcel.Cells(1, 2).Value = "Name"
objExcel.Cells(1, 2).Font.Bold = True
objExcel.Cells(1, 2).Interior.ColorIndex = 30
objExcel.Cells(1, 2).Font.ColorIndex = 2
objExcel.Cells(1, 3).Value = "Description"
objExcel.Cells(1, 3).Font.Bold = True
objExcel.Cells(1, 3).Interior.ColorIndex = 30
objExcel.Cells(1, 3).Font.ColorIndex = 2
For Each objUser In objDomain
IF objUser.AccountDisabled = False Then
objExcel.Cells(intRow, 1).Value = objUser.Name
objExcel.Cells(intRow, 2).Value = objUser.Fullname
objExcel.Cells(intRow, 3).Value = objUser.description
intRow = intRow + 1
End If
Next
Set objRange = objExcel.Range("A1")
objRange.Activate
Set objRange = objExcel.ActiveCell.EntireColumn
objRange.Autofit()
Set objRange = objExcel.Range("B1")
objRange.Activate
Set objRange = objExcel.ActiveCell.EntireColumn
objRange.Autofit()
Set objRange = objExcel.Range("C1")
objRange.Activate
Set objRange = objExcel.ActiveCell.EntireColumn
objRange.Autofit()
welcome to my scriptingblog.
Hopefully I will blog everyday about new scripting stuff.