I have converted a log file to an array, some elements in array contain the keyword Messages. I want a new array that only contains elements with that keyword.
I tried the following:
$Logfile_array = Get-Content "C:\temp\logfiles\complete_log.txt"
foreach ($array_element in $Logfile_array)
{
if ($array_element -match 'Messages')
{
foreach ($array_element in $Logfile_array)
{
$i++
echo $i
$array_message[$i] = $array_element
}
}
}
$array_elementsupposed to be in the inner loop, when you also use it in the outer loop?