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?