Skip to content

Instantly share code, notes, and snippets.

@MikeFal
Created January 21, 2016 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MikeFal/df2e2b0b5405f8cd5250 to your computer and use it in GitHub Desktop.
Save MikeFal/df2e2b0b5405f8cd5250 to your computer and use it in GitHub Desktop.
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null
$InstanceName = 'localhost'
$errlogs = (New-Object Microsoft.SqlServer.Management.Smo.Server $InstanceName).JobServer.EnumErrorLogs()
$FullLog = @()
$errlogs | ForEach-Object {$FullLog += $smosrv.JobServer.ReadErrorLog($_.ArchiveNo)}
$FullLog | Sort-Object LogDate -Descending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment