January 9, 2018 at 2:23 pm
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?
January 23, 2018 at 9:27 am
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
January 23, 2018 at 10:26 am
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.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply