VBS Script To Determine When All Users From A Specified Domain Password Was Last Changed

 

This VBS script will allow you to enter a Domain name from an input dialog box. The script will then write the appropriate Domain’s user names and the timestamp for when their Domain password was last changed. It will then write the results to an Excel spreadsheet.

 

VBS Script:

 

strDomain = InputBox ("Enter Domain Name")

 

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 = "Password Changed"

 

Set objContainer = GetObject("LDAP://CN=Users,DC=" & strDomain & ",DC=com")

objContainer.Filter = Array("User")

 

On Error Resume Next

For each objUser in objContainer

If left(objUser.objectCategory,9) = "CN=Person" Then

arrUser = Split(objUser.Name, "CN=")

objExcel.Cells(intRow, 1).Value = arrUser(1)

objExcel.Cells(intRow, 2).Value = objUser.PasswordLastChanged

 

intRow = intRow + 1

End If

Next

 

objExcel.Range("A1:B1").Select

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Range("A1:B1").Select

objExcel.Cells.EntireColumn.AutoFit

 

MsgBox "Done"

 

 

Published Sunday, August 26, 2007 12:00 PM by dhite
Filed under:

Comments

# VBS Scripts To Read Active Directory And Send All Computers Password Age To Excel

Here you will find two VBS scripts that will read Active Directory (AD) and return all of the machines

Sunday, November 25, 2007 7:59 AM by Don Hite

# re: VBS Script To Determine When All Users From A Specified Domain Password Was Last Changed

This script is suddenly just what I need, but it returns a "Line 11 Character 1 A Referral was returned from the server. 8007202b" error.

I should point out that our user are not in the "users" container, but in multiple containers under CN=Container1, CN=Container2, and then multiple container with user accounts by gepgraphic locaton. I tried modifying the script to drill down to a container with users in it, but got the same error.

It doesn't look like this script follows containers recursively.

Your recent script to return machine password age works without issue.

Wednesday, November 28, 2007 10:37 PM by pwstrain

# re: VBS Script To Determine When All Users From A Specified Domain Password Was Last Changed

If your Nested OU is Container1/Location1/Users1 then change the line to read:

Set objContainer = GetObject("LDAP://OU=Users1,OU=Location1,OU=Container1,DC=" & strDomain & ",DC=com")

Don

Thursday, November 29, 2007 3:19 PM by dhite

# VBS Script To Determine When All Users From A Nested OU and Specified Domain Password Was Last Changed - Don Hite

Pingback from  VBS Script To Determine When All Users From A Nested OU and Specified Domain Password Was Last Changed - Don Hite