Get-DbaAgentLog

Gets the “SQL Agent Error Log” of an instance. Returns all 10 error logs by default.

Screenshots

dbatools - Get-DbaAgentLog

Examples

Returns the entire error log for the SQL Agent on sql01\sharepoint

Get-DbaAgentLog -SqlInstance sql01\sharepoint

Returns log numbers 3 and 6 for the SQL Agent on sql01\sharepoint

Get-DbaAgentLog -SqlInstance sql01\sharepoint -LogNumber 3, 6

Returns the most recent SQL Agent error logs for “sql2014″,”sql2016” and “sqlcluster\sharepoint”

$servers = “sql2014″,”sql2016”, “sqlcluster\sharepoint”
$servers | Get-DbaAgentLog -LogNumber 0

Author

This command was created by Chrissy LeMaire. You can find Chrissy on Twitter and her blog.