By David Wiseman (Administrator)Created 08 Feb 2008
My Rating:
Vote
Rating:
Not Rated
Views:9332
Downloads:74

Copy the Previous Day’s Event Log Events to a Database

Language:  VBScript

Compatibility

Windows XP Yes Windows 2003 Yes
Windows 2000 No Windows NT No
Vista Unknown Windows 2008 Unknown
Description

Retrieves events from all the event logs that were recorded on the previous day, and writes these records to a database with the DSN Name EventLogs.

Code

Line Numbers: On  Off      Plain Text
Set objConn = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")

objConn.Open "DSN=EventLogs;"
objRS.CursorLocation = 3
objRS.Open "SELECT * FROM EventTable" , objConn, 3, 3

Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
Set dtmEndDate = CreateObject("WbemScripting.SWbemDateTime")

DateToCheck = Date - 1
dtmEndDate.SetVarDate Date, True
dtmStartDate.SetVarDate DateToCheck, True

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colEvents = objWMIService.ExecQuery _
    ("Select * from Win32_NTLogEvent Where TimeWritten >= '" _ 
        & dtmStartDate & "' and TimeWritten < '" & dtmEndDate & "'") 

For each objEvent in colEvents
    objRS.AddNew
    objRS("Category") = objEvent.Category
    objRS("ComputerName") = objEvent.ComputerName
    objRS("EventCode") = objEvent.EventCode
    objRS("Message") = objEvent.Message
    objRS("RecordNumber") = objEvent.RecordNumber
    objRS("SourceName") = objEvent.SourceName
    objRS("TimeWritten") = objEvent.TimeWritten
    objRS("Type") = objEvent.Type
    objRS("User") = objEvent.User
    objRS.Update
Next

objRS.Close
objConn.Close

 


Got a useful script? Click here to upload!


 

  Post Comment
Order By:  
User Comments
      

Posted On: 9/28/2018 1:29:08 AM

ugg outlet canada goose outlet cheap jerseys air jordan 4 polo ralph lauren ugg outlet christian louboutin outlet coach outlet online polo ralph lauren michael kors outlet pandora outlet ugg outlet canada goose outlet canada goose outlet true religion jeans vibram fivefingers adidas nmd shoes moncler jackets true religion outlet yeezy boost ugg outlet air max 90 uggs outlet nike huarache pandora jewelry ugg boots clearance michael kors outlet michael kors handbags canada goose outlet canada goose outlet pandora charms true religion jeans nfl jerseys wholesale canada goose jackets coach outlet christian louboutin outlet coach outlet christian louboutin outlet longchamp handbags michael kors outlet michael kors outlet pandora charms christian louboutin outlet christian louboutin outlet canada goose jackets adidas yeezy michael kors outlet polo ralph lauren valentino outlet coach outlet pandora jewelry pandora outlet mont blanc pens air max 90 birkenstock outlet nike trainers nike outlet lebron james shoes coach outlet adidas outlet kate spade outlet polo outlet hermes birkin kate spade outlet moncler outlet uggs outlet ray ban sunglasse mont blanc pens michael kors handbags polo ralph lauren coach outlet coach outlet coach outlet online canada goose jackets coach outlet store online coach outlet online mbt shoes polo ralph lauren coach outlet pandora jewelry moncler outlet canada goose outlet pandora jewelry michael kors outlet michael kors outlet pandora outlet coach factory outlet ray ban sunglasses canada goose outlet michael kors outlet ugg outlet canada goose jackets michael kors outlet coach outlet ralph lauren uk christian louboutin outlet michael kors outlet oakley sunglasses wholesale polo outlet coach outlet adidas outlet nfl jerseys wholesale christian louboutin outlet nike shoes canada goose jackets cheap nfl jerseys lebron james shoes coach outlet kate spade outlet polo shirts christian louboutin outlet ferragamo outlet cheap ugg boots michael kors outlet clearance superdry clothing michael kors handbags oakley sunglasses wholesale coach outlet coach outlet canada canada goose outlet michael kors outlet north face jackets kate spade outlet cheap ugg boots polo ralph lauren canada goose outlet true religion outlet store kate spade outlet michael kors outlet coach outlet online fred perry polo shirts ultra boost christian louboutin outlet prada outlet christian louboutin outlet kate spade outlet off white clothing kate spade outlet moncler jackets kate spade outlet christian louboutin outlet air jordan shoes coach outlet online kate spade outlet pandora outlet christian louboutin outlet moncler jackets polo ralph lauren mbt shoes ugg outlet coach outlet ugg outlet ralph lauren polo michael kors handbags ralph lauren outlet coach factory outlet cheap jordans chaussures christian louboutin michael kors outlet ugg outlet kate spade outlet canada goose jackets polo outlet michael kors outlet nfl jerseys pandora outlet coach outlet coach factory outlet ray ban sunglasse supreme uk michael kors outlet nfl jerseys canada goose jackets coach outlet true religion outlet scarpe mbt michael kors outlet air max 2017 nfl jerseys wholesale pandora jewelry outlet cheap jordans coach outlet online ray ban outlet nfl jerseys wholesale michael kors outlet coach factory outlet michael kors outlet christian louboutin outlet canada goose outlet coach outlet oakley sunglasses wholesale michael kors outlet clearance supreme outlet mont blanc pens coach factory outlet cheap mlb jerseys true religion jeans nba jersey mlb jerseys wholesale ray ban sunglasses canada goose outlet christian louboutin outlet oakley sunglasses nike shoes cheap nfl jerseys birkenstock shoes ed hardy clothing oakley sunglasses mulberry handbags ralph lauren shirts michael kors outlet nike outlet coach outlet michael kors outlet polo ralph lauren cheap nfl jerseys ugg boots michael kors outlet coach outlet asics running shoes pandora charms michael kors outlet nfl jerseys wholesale pandora charms pandora charms uggs outlet uggs outlet christian louboutin mbt shoes canada goose outlet tory burch outlet coach factory outlet pandora charms michael kors outlet coach outlet yeezy boost ralph lauren sale clearance mulberry handbags adidas nmd mlb jerseys canada goose outlet coach outlet michael kors outlet ugg outlet kate spade outlet ugg outlet ray ban sunglasse adidas yeezy mulberry handbags coach outlet mbt shoes nike outlet michael kors outlet pandora outlet mbt shoes ugg boots nike shoes outlet coach factory outlet michael kors outlet clearance coach outlet online coach outlet north face jackets ugg outlet polo outlet yeezy boost polo ralph lauren christian louboutin outlet polo ralph lauren ralph lauren polo shirts coach outlet online adidas nmd ugg outlet coach outlet coach outlet fitflops sale clearance pandora outlet valentino outlet nike shoes coach outlet michael kors handbags canada goose jackets michael kors handbags canada goose outlet fitflops sale clearance ray ban sunglasses cheap oakley sunglasses polo outlet moncler outlet canada goose outlet adidas yeezy shoes coach outlet nfl jerseys oakley sunglasses wholesale polo ralph lauren kate spade outlet ray ban sunglasses canada goose jackets adidas outlet coach outlet pandora outlet michael kors outlet coach outlet coach outlet online cheap ray bans sunglasses coach outlet michael kors outlet lunette ray ban michael kors taschen michael kors outlet true religion outlet nike outlet christian louboutin outlet ugg boots pandora charms air jordan retro coach outlet mont blanc pens nhl jerseys red bottom shoes true religion outlet mbt shoes louboutin shoes michael kors outlet asics shoes canada goose jackets polo ralph lauren gucci outlet christian louboutin outlet coach outlet coach outlet canada goose rolex watches michael kors handbags coach factory outlet michael kors outlet pandora charms sale clearance canada goose outlet polo ralph lauren pas cher oakley sunglasses michael kors outlet giuseppe zanotti outlet canada goose outlet polo outlet canada goose outlet moncler jackets christian louboutin outlet coach factory outlet nike outlet coach outlet online nike outlet tory burch outlet kate spade handbags fred perry polo fred perry polo shirts red bottom shoes cheap ugg boots coach outlet cheap nfl jerseys coach outlet ralph lauren shirts true religion jeans christian louboutin boutique north face jackets prada handbags christian louboutin outlet nfl jerseys christian louboutin outlet pandora jewelry polo ralph lauren mcm handbags moncler outlet true religion outlet polo ralph lauren polo outlet cheap nfl jerseys coach outlet cheap ugg boots coach outlet online pandora jewelry pandora jewelry mbt shoes pandora outlet nfl jerseys pandora charms coach outlet uggs outlet coach outlet online longchamp outlet coach outlet nike air max ugg boots ugg boots michael kors handbags canada goose jackets adidas superstar shoes cheap snapbacks giuseppe zanotti outlet adidas shoes michael kors outlet red bottom shoes fitflops sale clearance pandora charms christian louboutin outlet canada goose outlet coach outlet polo ralph lauren fitflops sale clearance christian louboutin outlet coach outlet mulberry handbags oakley sunglasses michael kors outlet michael kors handbags gucci outlet michael kors outlet moncler outlet north face jackets mcm outlet puma outlet coach outlet nhl jerseys cheap jordans uggs outlet hermes belts manolo blahnik outlet cheap ugg boots michael kors outlet ralph lauren outlet ugg outlet north face jackets adidas outlet ralph lauren outlet polo ralph lauren ed hardy kate spade outlet ugg outlet canada goose jackets ralph lauren polo christian louboutin shoes uggs outlet canada goose jackets pandora charm ugg boots clearance cheap nfl jerseys canada goose jackets pandora jewelry cheap jerseys kate spade outlet yeezy boost ugg outlet michael kors outlet uggs outlet nike kyrie 3 off-white canada goose outlet pandora outlet lacoste outlet nike shoes michael kors outlet michael kors outlet oakley sunglasses tory burch outlet coach outlet ralph lauren outlet ugg boots ralph lauren outlet kate spade outlet polo ralph lauren christian louboutin outlet pandora outlet michael kors outlet ugg outlet coach outlet red bottoms michael kors outlet uggs canada ugg boots nike outlet polo ralph lauren uggs outlet coach outlet christian louboutin outlet converse adidas nmd pandora jewelry coach outlet true religion jeans yeezy boost 350 coach outlet polo outlet christian louboutin outlet fred perry outlet michael kors handbags oakley sunglasses ray ban sunglasses polo ralph lauren uggs outlet canada goose outlet canada goose outlet canada goose jackets michael kors handbags clarks shoes adidas yeezy pandora charms oakley sunglasses kate spade outlet prada outlet ferragamo shoes tory burch outlet valentino outlet polo outlet coach outlet online uggs canada true religion jeans canada goose outlet coach outlet online christian louboutin shoes pandora outlet pandora outlet michael kors outlet kate spade outlet michael kors uk michael kors outlet michael kors outlet canada goose jackets cheap jordans polo outlet ugg boots longchamp outlet michael kors outlet christian louboutin outlet michael kors outlet pandora outlet ray ban sunglasse supreme ugg boots michael kors outlet rolex watches kobe bryant shoes moncler outlet canada goose vans shoes michael kors outlet michael kors outlet kebirong20180928