Home Forums Programming Powershell Is anyone scanning event logs with powershell? RE: Is anyone scanning event logs with powershell?

  • 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