scripting - Powershell - help. Search and name file -


i appreciate feedback or assistance

the problem having have folder contains log files of machines i'm working with. have several scripts search logs looking predetermined strings, have script generate report based on count of each outcome. however, additionally tell machine name of each string outcome. also, not display if nothing found. fortunately, i've titled each log file machine name in hopes if finds string inside log have name title of log file found in.

could provide assistance script? i've attempted various scripts using gci , if statements no avail.

thanks!

$items = get-childitem "path-to-file"    foreach ($item in $items)  {  if ($items -contains "success") { write-host $items.name }  } 

you should use get-content query file contents.

foreach ($item in $items) {     if ((get-content $item) -match "success") {         $item.name     } } 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -