Get-FileHash
Use Get-FileHash to compute a cryptographic hash of a file, defaulting to SHA256.
Documentation: Microsoft Learn — Get-FileHash
Syntax
See the command anatomy
Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.
Get-FileHash [-Path] <String[]> [-Algorithm <String>] [<CommonParameters>]- Stage 1Get-FileHash
-Path -Algorithm
Try it
PowerShell example · browser support is limited.
Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.
Follow the objects
Run the command to inspect each stage.
Examples
Select Algorithm, Hash
Show reference output
Sample output · fictional data, shaped like the real thing
Algorithm Hash Path --------- ---- ---- SHA256 2F8C9C2D9E428E5F3C8B0E8D66F8D8FA103A238A45A690C8D9B9239A0F849DB4 C:\Temp\file.zip
Select first 3
Show reference output
Sample output · fictional data, shaped like the real thing
Algorithm Hash Path --------- ---- ---- SHA256 2F8C9C2D9E428E5F3C8B0E8D66F8D8FA103A238A45A690C8D9B9239A0F849DB4 C:\Temp\file.zip
Get-FileHash -Algorithm MD5
Show reference output
Sample output · fictional data, shaped like the real thing
Algorithm Hash Path --------- ---- ---- MD5 2F8C9C2D9E428E5F3C8B0E8D66F8D8FA103A238A45A690C8D9B9239A0F849DB4 C:\Temp\file.zip
Parameters
Parameter definitions:
-Path-Algorithm
Practical use and troubleshooting
Practical scenario: Use Get-FileHash when you need to compute a cryptographic hash of a file, defaulting to SHA256. Review syntax and sample output, then try an example in the browser lab. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.
Common error and fix: A mismatch may indicate a different version or changed bytes. Confirm the expected algorithm and obtain the reference digest from a trusted source before accepting the file. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.
See also: Get-AuthenticodeSignature. Get-FileHash calculates a file digest; Get-AuthenticodeSignature examines its signature. A matching hash needs a trusted reference value and is not evidence of a trusted publisher by itself. Read the linked command before substituting it; similar names do not imply identical inputs or output.
Recap
Get-FileHash Use Get-FileHash to compute a cryptographic hash of a file, defaulting to SHA256.
Next: Get-Acl