Get-Filehash SHA256 encryption in powershell drops last 4 digits when run from a batch file

Viewed 2216

When I run the Get-Filehash from powershell it works however:

When I run it from a batch file, it drops last 4 digits.

powershell.exe -NoProfile -ExecutionPolicy -Command "Get-FileHash filename.edi -Algorithm SHA256 | Out-File c:\app\testfileout.txt"
Algorithm       Hash                                                           
---------       ----                                                           
SHA256          3EFEC59BFB0573061C5CD2F72A684663B60CA3D0D91C67CBDBBE366A59FE...

How do I get the output file to ONLY be:

3EFEC59BFB0573061C5CD2F72A684663B60CA3D0D91C67CBDBBE366A59FE4A8F

Which gives me the full hash inside Powershell when I run this:

Get-FileHash filename.edi -Algorithm SHA256 | Out-File c:\app\testfileout.txt

I need just the hash without the headers as well as the final 4 digits.

Does anyone have a script that already does this?

2 Answers
Related