Get last logon from net user AD not installed on server

818 views Asked by At

When I run net user , I get the great screen of information. One of of the items Last Logon would be great to see in a report. I've tried all the powershell and vbs scripts I can find, but they all seem to require Active Directory. I'm looking for a batch file that will create a report listing the last logon for all my users.

1

There are 1 answers

2
MC ND On
@if (@This==@IsBatch) @then
@echo off
rem **** batch zone *********************************************************

    setlocal enableextensions disabledelayedexpansion

    cscript //nologo //E:JScript "%~f0"

    rem End of batch area. Ensure batch ends execution before reaching
    rem javascript zone
    exit /b

@end
// **** Javascript zone *****************************************************

var dict = new ActiveXObject("Scripting.Dictionary"); 
    dict.Add("u","user");

var computer=GetObject("WinNT://."); 
    computer.Filter = dict.Items();

for (var users = new Enumerator(computer) ;!users.atEnd();users.moveNext()){
    var user=users.item();
    try { var lastLogin = user.LastLogin; } catch (e) { lastLogin='never' };
    WScript.StdOut.WriteLine(user.Name+'='+lastLogin);
}