Hi, I am running a script to collect a count of all errors in the current error log using smo, as below:
$sqlServer = new-object ("Microsoft.SqlServer.Management.Smo.Server") "MYSERVER"
$logs = $sqlServer.ReadErrorLog() | where {($_.Text -like "Error*" -or $_.Text -like "*Fail*") -and ($_.Text -notlike "*Found 0 Errors*")};
$count = $logs.Count
$count
and then dumping this into a monitor database.
This works fine for most servers, but I have a 2005 cluster that for some reason won't return the count. If I just read the error log into console that works fine, but the .Count method disappears completely from the object. It is like, for this server, the object returned from $sqlServer.ReadErrorLog() is different to the rest of the servers.
Any ideas?
Thanks for reading.