WSH - List Users Last Login Date/Time
/**
* Script: getLastLogin.js
* Purpose: Returns the Last time a user logged in.
* Author: Daren Thiel
* Date: 25 Mar 2001
* Web: http://www.winscripter.com
**/
// Print out the last time "someuser" logged into "ComputerA"
WScript.Echo( getLastLogin( "ComputerA", "someuser" ) );
/**
* getLastLogin - Returns the Last Login time for a user
* in the format of "3/25/01 7:07:23 AM"
*
* example - var ll = getLastLogin( "DOMAIN", "someuser" );
* - var ll = getLastLogin( "DOMAIN/Computer", "someuser" );
**/
function getLastLogin( domain, user )
{
try
{
var m_user = GetObject( "WinNT://" + domain + "/" + user + ",user" );
return( m_user.LastLogin );
}
catch( e )
{
return( "Error: " + e.description );
}
}