Различия

Здесь показаны различия между двумя версиями данной страницы.

Ссылка на это сравнение

spisok_polzovatlej_ne_loginivshixsja_v_ad_n_dnej [2013/10/23 15:38] (текущий)
Строка 1: Строка 1:
 +<code vb lastlogin.vbs>​
 +//​~~Author~~. Paul stuart ​
 +//​~~Email_Address~~. Paul.Stuart@schroders.com ​
 +//​~~Script_Type~~. Jscript ​
 +//​~~Sub_Type~~. DomainAdministration ​
 +//​~~Keywords~~. ADSI, last login date, domain, login 
  
 +//​~~Comment~~. ​
 +//Create a report showing users who haven'​t logged in to the Domain for X days or more. 
 +//Requires ADSI 2.5 and Jscript version 5. The results are sent to LOGFILE.TXT ​
 +
 +//​~~Script~~. ​
 +
 +var sDomain = "";​ // enter your domain here. 
 +var iCutOffDays = 0; // last login cut-off in days. 
 +
 +var TRUE = 1; 
 +var ForReading = 1; 
 +var ForWriting = 2; 
 +var DAYMSECS = 86400000; // number of milliseconds in a day 
 +var DomObj, CollObj, sSubDir; ​
 +var iNumUsers = 0; 
 +var CutOff; ​
 +
 +var WSHShell = new ActiveXObject("​WScript.Shell"​); ​
 +var fs = new ActiveXObject("​Scripting.FileSystemObject"​); ​
 +
 +WSHShell.Popup("​Starting Last Log Report " ); 
 +
 +CutOff = new Date(); ​
 +CutOff.setTime( CutOff.valueOf() - iCutOffDays*DAYMSECS ); 
 +
 +DomObj = GetObject("​WinNT://"​ + sDomain ); 
 +CollObj = new Enumerator(DomObj); ​
 +
 +for ( ; !CollObj.atEnd();​ CollObj.moveNext()) ​
 +
 +var Obj = CollObj.item(); ​
 +if ( Obj.Class == "​User"​ ) 
 +
 +iNumUsers++; ​
 +try 
 +
 +if ( Obj.LastLogin < CutOff.valueOf() ) 
 +WriteLOG( Obj.name + " " + Obj.LastLogin ); 
 +
 +catch( ErrorObj ) 
 +
 +WriteLOG( Obj.name + " has never logged in" ); 
 +
 +
 +
 +
 +WriteLOG("​Total number of users is " + iNumUsers ); 
 +
 +WSHShell.Popup("​Finished"​); ​
 +WScript.Quit(); ​
 +
 +////////////////////////////////////////////////////////////////////////////////// ​
 +// WriteLOG ​
 +// 
 +var LogFile = new Object(); ​
 +
 +function WriteLOG( sLogLine ) 
 +
 +var d = new Date(); ​
 +
 +if ( LogFile == null ) 
 +
 +LogFile = fs.OpenTextFile( "​.\\Logfile.txt"​ , ForWriting, TRUE ); 
 +LogFile.WriteLine( sLogLine ); 
 +
 +else 
 +
 +LogFile.WriteLine( sLogLine ); 
 +
 +}
 +</​code>​
spisok_polzovatlej_ne_loginivshixsja_v_ad_n_dnej.txt · Последние изменения: 2013/10/23 15:38 (внешнее изменение)
GNU Free Documentation License 1.3
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 Яндекс.Метрика