I am trying to get the contents of a file as hex in Powershell, and I am using the following:
get-content -encoding byte $fullFilePath | %{"{0:X2}" -f $_} | %{$hex = $hex + $_}
When I run this script, I do not get an error, but it does not return, it just hangs.
Any ideas?
Thanks.
$fullFilePath? You can skip the secondForEach-Objectas well:Get-Content $fullFilePath -Encoding Byte | %{ $hex += "{0:X2}" -f $_ }-- tested with a few smaller files and$hexis populated very quickly. Testing with a 43MB PDF and it's been running for over two minutes.