Get-FileHash
Check a file's hash (checksum)
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
| Shell | What you might type |
|---|---|
| bash / zsh | sha256sum installer.exe |
| cmd.exe | certutil -hashfile installer.exe SHA256 |
More in From bash and From cmd.