Apply -list after -pattern and showing a count for compressed findings

Hello and good afternoon!

I have a problem, and I was wondering if anyone could help me on here. With the help of a co-worker, I was able to create a script that does following 

first the code reads a text file and using the get-content cmd to loop through a list of servers

Once this is complete I use a get-item along with a select string to to filter out what I want per server

                                           

$severNames = Get-content c:\Users\myusername\Desktop\serverNames.txt 
$date = Get-Date -format "yyyy_MM_dd"

foreach ($serverName in $serverNames)
{

       $serversPath = "\\$serverName\ITG\Logs\SLS_*-sls*_"


              $com = Get-Item $serversPath$date.txt | select-string -pattern "Starting cache refresh" -list
              $com2 = $com -replace (".*Completed.*")
              $e = $com2 | where { $_ -ne "" }

              $a = get-item $serversPath$date.txt | select-string -pattern "deserializing symbolCountry data from temp file" -list
                $c = $a -replace (".*Completed.*")
              $b = $c | where { $_ -ne "" }
              $serverName ,$b,  $e + "`n"



}

This works fine as it shows me the pattern per file in each server. Each server has 8 files where both of the patterns show up.

I am only applying -list because it condenses my findings, but what I want to do is have a count for each file based on how many times both of the messages appear in each file. There are 4 servers so 32 logs in total, so i would like to see a comparison on each file for the two messages. I tried a measure-object -line, but it returns a generic messages could someone shine light on this is a sample 

1:49.13700) SLS(3484.5): Deserializing symbolCountry data from tem
SH.3484\bf2ab437-cfcb-409f-b79c-91dbdfe01d94'
:56:13.90100) SLS(2164.57): Deserializing symbolCountry data from 
FRESH.2164\c8a7fee7-5ace-47ee-ad8d-3f4c1b78e741'
9:34.43500) SLS(3856.26): Deserializing symbolCountry data from te
ESH.3856\8b63efdb-f5a1-4921-9ddd-19ca66333575'
1:01.90500) SLS(2792.40): Deserializing symbolCountry data from te
ESH.2792\9727c387-33d3-46b4-90ed-0d531bdc383d'
8:49.77200) SLS(2088.79): Deserializing symbolCountry data from te
ESH.2088\3f2835ea-2630-4ecb-99a6-34266c77af25'
8:01.47500) SLS(3472.76): Deserializing symbolCountry data from te
ESH.3472\17d38d00-c073-48d2-942b-67e9201fc0db'
0:18.08500) SLS(5756.6): Deserializing symbolCountry data from tem
SH.5756\b5a9a843-40f5-4b16-93d2-37d30cac09cc'
7:30.55500) SLS(2152.51): Deserializing symbolCountry data from te
ESH.2152\2b7e6d32-8b7c-4a6a-847f-2082ec328d9c'
22:02.45900) SLS(3484.5): Starting cache refresh for 'SLS09.Search

:21:49.13700) SLS(2164.105): Starting cache refresh for 'SLS10.Sea

19:48.47800) SLS(3856.26): Starting cache refresh for 'SLS11.Searc

21:16.26600) SLS(2792.40): Starting cache refresh for 'SLS12.Searc

19:03.58600) SLS(2088.79): Starting cache refresh for 'SLS13.Searc

18:15.37700) SLS(3472.76): Starting cache refresh for 'SLS14.Searc

20:32.22100) SLS(5756.6): Starting cache refresh for 'SLS15.Search

17:44.82000) SLS(2152.51): Starting cache refresh for 'SLS16.Searc

each message here has more of the same messages so since I used - list I only see when it happens it would be nice to just show the count for each instance for which I see the messages below

for security reason I removed the server and file name but for each start cache refresh that message occurs several time in each file, so I want to see that for both 

could some one help

July 28th, 2015 2:10pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics