'The script checks the Computers OU in Active Directory and displays computer name,OS, and last time password set
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile("C:\log\passwordreset.log", 2, True) 'Appends to Log File
Set objShell = WScript.CreateObject("WScript.Shell")
ts.WriteLine "Script started successfully on" & " " & Now
ts.WriteBlankLines(2)
//edit ldapb elow. this checks computers container
Set objOU = GetObject("LDAP://CN=Computers,DC=foo,DC=com")
ObjOu.Filter = Array("computer")
For Each objComputer in ObjOU 'Loops through each computer account in Computers OU
Set objPwdLastSet = objComputer.pwdLastSet
intPLS = Integer8Date(objPwdLastSet,lngTZBias)
StrCN = ObjComputer.CN 'Retrieve Computer Name
StrOS = ObjComputer.operatingSystem 'Retrieve Operating System
'StrPW = ObjComputer.pwdLastSet
'Test Operating System of each pc
ts.WriteLine "Computer Name:" & StrCN & " " & StrOS & " " & intPLS
'Set objPwdLastSet = objComputer.pwdLastSet
'intPLS = Integer8Date(objPwdLastSet,lngTZBias)
Next
ts.WriteLine "Script completed successfully on" & " " & Now
ts.WriteBlankLines(2)
ts.Close
Function Integer8Date(objDate, lngBias)
' Function to convert Integer8 (64-bit) value to a date, adjusted for
' local time zone bias
Dim lngAdjust, lngDate, lngHigh, lngLow
lngAdjust = lngBias
lngHigh = objDate.HighPart
lngLow = objdate.LowPart
' Account for error in IADslargeInteger property methods.
If lngLow < 0 Then
lngHigh = lngHigh + 1
End If
If (lngHigh = 0) And (lngLow = 0) Then
lngAdjust = 0
End If
lngDate = #1/1/1601# + (((lngHigh * (2 ^ 32)) _
+ lngLow) / 600000000 - lngAdjust) / 1440
' Trap error if lngDate is ridiculously huge.
On Error Resume Next
Integer8Date = CDate(lngDate)
If Err.Number <> 0 Then
On Error GoTo 0
Integer8Date = #1/1/1601#
End If
On Error GoTo 0
End Function