﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Programming / Powershell  / collecting a count of errorlogs using posh / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 18 Jun 2013 21:15:07 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: collecting a count of errorlogs using posh</title><link>http://www.sqlservercentral.com/Forums/Topic1421657-1351-1.aspx</link><description>I think I may have answered my own question.It appears that the ReadErrorLog function is returning it's own error, rather than a collection of errors from the server log, which is where my confusion lay. As it is a single error, there is no collection / count for it. This happens when it connects okay to the server to return an smo object, but the function call returns an authentication error.</description><pubDate>Tue, 19 Feb 2013 08:25:05 GMT</pubDate><dc:creator>Simon D Richards</dc:creator></item><item><title>collecting a count of errorlogs using posh</title><link>http://www.sqlservercentral.com/Forums/Topic1421657-1351-1.aspx</link><description>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$countand 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.</description><pubDate>Tue, 19 Feb 2013 07:57:40 GMT</pubDate><dc:creator>Simon D Richards</dc:creator></item></channel></rss>