Skip to content

Instantly share code, notes, and snippets.

@kfstorm
Created July 18, 2015 14:54
Show Gist options
  • Save kfstorm/0eed39dc632fb7e3bead to your computer and use it in GitHub Desktop.
Save kfstorm/0eed39dc632fb7e3bead to your computer and use it in GitHub Desktop.
Detect BOM in batch files
[byte[]] $WrongBytes = 0x00,0xEF,0xFE,0xFF
Get-ChildItem -Include *.bat,*.cmd -Recurse | ForEach-Object {
$content = Get-Content $_ -Encoding Byte
if ($WrongBytes.Contains($content[0]))
{
echo $_.FullName
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment