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.
问问题
771 次
1 回答
0
@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);
}
于 2014-01-19T15:04:22.613 回答