Tag Archives: MimboloveSQL Agent Logs

How to read SQL Agent logs using Windows PowerShell

Written by Tao Yang

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'<strong>)”<SQL Instance Name>”</strong>

$SQLAgent = $Sql.JobServer

$SQLAgent.ReadErrorLog() | format-list *