coolstorm6
IS-IT--Management
Kindly i need your support when i run this Script on any target pc i gor this error 800A000D Cdate Problem
please Advice
Option Explicit
Dim objWMIService, objComputer, colComputer, colItems, objItem
Dim strLogonUser, strLogonUser1, strComputer, dtmWMIDate, strReturn, sDateAndTime
strComputer = "."
strComputer = InputBox("Enter Computer NAME HERE", _
"Find Logon User", strComputer)
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_NetworkLoginProfile")
For Each objItem in colItems
Wscript.Echo "Full Name: " & objItem.FullName
dtmWMIDate = objItem.LastLogoff
strReturn = WMIDateStringToDate(dtmWMIDate)
Wscript.Echo "Last Logoff: " & strReturn
dtmWMIDate = objItem.LastLogon
strReturn = WMIDateStringToDate(dtmWMIDate)
Wscript.Echo "Last Logon: " & strReturn
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "Number Of Logons: " & objItem.NumberOfLogons
Next
Function WMIDateStringToDate(dtmWMIDate)
Dim sDateAndTime
If Not IsNull(dtmWMIDate) Then
WMIDateStringToDate = cdate(Mid(dtmWMIDate, 5, 2) & "/" & _
Mid(dtmWMIDate, 7, 2) & "/" & Left(dtmWMIDate, 4) _
& " " & Mid (dtmWMIDate, 9, 2) & ":" & _
Mid(dtmWMIDate, 11, 2) & ":" & Mid(dtmWMIDate, 13, 2))
End If
End Function
please Advice
Option Explicit
Dim objWMIService, objComputer, colComputer, colItems, objItem
Dim strLogonUser, strLogonUser1, strComputer, dtmWMIDate, strReturn, sDateAndTime
strComputer = "."
strComputer = InputBox("Enter Computer NAME HERE", _
"Find Logon User", strComputer)
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_NetworkLoginProfile")
For Each objItem in colItems
Wscript.Echo "Full Name: " & objItem.FullName
dtmWMIDate = objItem.LastLogoff
strReturn = WMIDateStringToDate(dtmWMIDate)
Wscript.Echo "Last Logoff: " & strReturn
dtmWMIDate = objItem.LastLogon
strReturn = WMIDateStringToDate(dtmWMIDate)
Wscript.Echo "Last Logon: " & strReturn
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "Number Of Logons: " & objItem.NumberOfLogons
Next
Function WMIDateStringToDate(dtmWMIDate)
Dim sDateAndTime
If Not IsNull(dtmWMIDate) Then
WMIDateStringToDate = cdate(Mid(dtmWMIDate, 5, 2) & "/" & _
Mid(dtmWMIDate, 7, 2) & "/" & Left(dtmWMIDate, 4) _
& " " & Mid (dtmWMIDate, 9, 2) & ":" & _
Mid(dtmWMIDate, 11, 2) & ":" & Mid(dtmWMIDate, 13, 2))
End If
End Function