All Forums >> [Scripting] >> Post a VBScript >> Collects Administrator Failed Logon Event Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
'********************************************************************************************************************** '* This script collects from the machine, the Administrator Failed Logon entrys from the local Security Event Logs. * '* ------------------------------------- * '* Written by: Jeferson Propheta and Ricardo Calina * '* December / 2006 * '**********************************************************************************************************************
Option Explicit
Dim objFso, objFolder, objWMI, objEvent ' Objects Dim strFile, strComputer, strFolder, strFileName, strPath ' Strings Dim intEvent, intNumberID, intRecordNum, colLoggedEvents, objShell, srtUsename, wMessage, wPesq
' ---------------------------------------- ' Folder Creation Set objFso = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strFolder) Then Set objFolder = objFSO.GetFolder(strFolder) Else Set objFolder = objFSO.CreateFolder(strFolder) Wscript.Echo "Folder created " & strFolder End If Set strFile = objFso.CreateTextFile(strPath, True)
'-------------------------------------------- ' File Creation ' Then creates WMI connector to the Logs
Set objWMI = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate,(Security)}!\\" _ & strComputer & "\root\cimv2") Set colLoggedEvents = objWMI.ExecQuery _ ("Select * from Win32_NTLogEvent Where Logfile = 'Security' AND EventCode = 529")