SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Is anyone scanning event logs with powershell?


Is anyone scanning event logs with powershell?

Author
Message
alen teplitsky
alen teplitsky
One Orange Chip
One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)

Group: General Forum Members
Points: 27097 Visits: 4910
Wrote my first poweshell function and used get-eventlog. Problem it runs very slow even with filtering on a dozen servers. I just read about get-winevent, but people complain about about similar problems.

My question is does anyone scan dozens of servers worth of event logs for errors daily with Powershell? How long does it take?
bruce 1565
bruce 1565
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2366 Visits: 1132
Part of a script to track SQL Server availability includes the three lines below. Checking 41 servers, inserting the results into staging tables on a separate SQL Server, de-duping those results and saving the remainder to the permanent table takes one minute on average (77 to 51 seconds min/max).
I run the script from a SQL Agent job configured as an operating system type and scheduled very early morning so I don't notice length of time to execute.
I tried Get-EventLog and agree, it was very slow compared to Get-WinEvent.


$hostDown = Get-WinEvent -ComputerName $($server) -FilterHashtable @{logname="application"; providername="MSSQLSERVER"; id=17147} |select TimeCreated, id
$serverDown = Get-WinEvent -ComputerName $($server) -FilterHashtable @{logname="application"; providername="MSSQLSERVER"; id=17148} |select TimeCreated, id
$hostUp = Get-WinEvent -ComputerName $($server) -FilterHashtable @{logname="application"; providername="MSSQLSERVER"; id=3408} |select TimeCreated, id

RandomStream
RandomStream
SSCrazy
SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)

Group: General Forum Members
Points: 2953 Visits: 648
When I did my monitoring tasks with Powershell, I relied on LogParser.exe from Microsoft. It was an amazing piece of s/w with just one exe file. It marks the line at the end of each scan and carry on from that point for the next scan so it wastes no resources at all. I highly recommend it if it is still available.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search