Get-ChildItem -Recurse -Filter *.java | ForEach-Object { $b = [IO.File]::ReadAllBytes($_.FullName) if ($b.Length -ge 3 -and $b[0] -eq 0xEF -and $b[1] -eq 0xBB -and $b[2] -eq 0xBF) { Write-Output ("BOM: " + $_.FullName) } } Write-Output "scan done"