Commands / Files

Get-FileHash

Check a file's hash (checksum)

beginner Files

Get-FileHash
 Get-FileHash -Path .\installer.exe -Algorithm SHA256
Works on
WindowsLinuxmacOS
PowerShell
5.1 and later
Reference
Microsoft Learn: Get-FileHash

Download pages often publish a SHA256 "checksum." If your file's hash matches, you have exactly the file they published.

SHA256 is the default. You can also pass -Algorithm SHA1, SHA384, SHA512, or MD5, but only for matching an old published value; MD5 and SHA1 are not safe against tampering.

Try this

Compare against the published value. -eq ignores case, so upper or lower case both work:

$expected = 'PASTE-THE-PUBLISHED-HASH-HERE'
(Get-FileHash -Path .\installer.exe).Hash -eq $expected

True means it matches.

Find duplicate files by content:

Get-ChildItem -Path .\photos -File -Recurse |
    Get-FileHash |
    Group-Object -Property Hash |
    Where-Object Count -gt 1

Coming from another shell

ShellWhat you might type
bash / zshsha256sum installer.exe
cmd.execertutil -hashfile installer.exe SHA256

More in From bash and From cmd.

Related commands