powershell where-object -cnotmatch filter unwanted lines

46 Views Asked by At

command

Get-Content -Path 'temp.cmd' | where { $_ -cnotmatch '^::|REM|rem'} | Set-Content 'temp1.cmd' -Encoding utf8

should filter-out comments from batch file. The 'REM', 'rem' and '::' on the beginning of lines. But if filter out lines like this

<nul set /p =%E%10;10fError: check log file

too. What could be wrong?

0

There are 0 best solutions below