How to read SQL Agent logs using Windows PowerShell

less than 1 minute read

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 *

1

Leave a comment