I have files with content similar to one below:
SN1,Column2,Column3;
SN2,Column2,Column3;
SN3,Column2,Column3;
SN1,Column2,Column3;
SN2,Column2,Column3;
I need to create a PS script which will perform some action in them only in the case that it has word "SN1" more than once. Since they all have SN1 at the beginning of the file, the second instance of it should always have linefeed(\n). I tried regex to capture same logic to know if there are more than one SN1 but seems I am missing something :
foreach ($file in $List) {
$count = 0
[string]$content = Get-Content -Path $file.FullName
if ($content -match "(\n+SN1)")
{
$count++
}
if ($count -eq 1)
{
<< do something >>
}
else
{
<< do nothing >>
}
}
Thank you for any help