Windows Script Host  

WSH and Windows Management Instrumentation (WMI)

With WSH you can easily use Windows Management Instrumentation (WMI). The following scripts demonstrate using WSH and WMI to retrieve a user's logon time via ADSI.

Note   For more information on WMI, see the WMI SDK at (http://msdn.microsoft.com).
// JScript.
LoginProfiles = GetObject("winmgmts:").InstancesOf ("Win32_NetworkLoginProfile");
for(e = new Enumerator(LoginProfiles) ; !e.atEnd() ; e.moveNext())
{
   Profile = e.item();
   WScript.Echo(Profile.Name);
   WScript.Echo(Profile.LastLogon);
}

' VBScript.
Set LoginProfiles = GetObject("winmgmts:").InstancesOf ("Win32_NetworkLoginProfile")
   for each Profile in LoginProfiles 
      WScript.Echo Profile.Name
      WScript.Echo Profile.LastLogon
   next

See Also

Basic Windows Script Host Tasks