How to read SQL Agent logs using Windows PowerShell
Prerequisite: SQL Management Studio needs to be installed.
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.Smo') | Out-Null
$Sql = New-Object ('Microsoft.SqlServer.Management.Smo.Server')"SQL_Instance_Name"
$SQLAgent = $Sql.JobServer
$SQLAgent.ReadErrorLog() | format-list *
Leave a comment