Windows · Command Line

    Verify Files with PowerShell Get-FileHash (and Check a Whole Folder)

    Get-FileHash is the fastest way to verify a single file on Windows. Here's how to hash, compare, and verify downloads from PowerShell — and how to scale past a per-file loop when you need to check an entire folder, repeatably.

    Published June 30, 20269 min read
    Mehrab Ali

    Author

    Mehrab Ali

    Data Scientist, Researcher & Entrepreneur

    Founder of ARCED Foundation, ARCED International, and Solutions of Things Lab (SoTLab). Built FolderManifest to help teams protect file integrity and stay audit-ready.

    Quick answer

    To verify a file in PowerShell, run Get-FileHash "C:\Downloads\app.zip" — it returns the SHA-256 hash by default. To confirm a download, compare it to the published value with (Get-FileHash .\app.zip).Hash -eq 'EXPECTED' (case-insensitive, returns True). Get-FileHash hashes one file at a time; to verify a whole folder repeatably, generate a manifest baseline once and verify against it.

    • Get-FileHash file → SHA-256 by default; add -Algorithm MD5 to switch.
    • Compare with -eq — it's case-insensitive, so paste any-case hashes.
    • Folders need a loop — and a loop has no baseline and no diff.
    • A manifest fixes that: one verify call, one pass/fail exit code.

    Hash a single file

    Get-FileHash ships with every modern Windows PowerShell — nothing to install. Point it at a file and it returns the algorithm, the hash, and the path:

    PowerShell
    Get-FileHash "C:\Downloads\app.zip"
    
    Algorithm       Hash                                                              Path
    ---------       ----                                                              ----
    SHA256          9F86D081884C7D659A2FEAA0C55AD015A3BF4F1B2B0B822CD15D6C15B0F00A08  C:\Downloads\app.zip

    SHA-256 is the default. To use a different algorithm, pass -Algorithm — the supported values are SHA1, SHA256, SHA384, SHA512, and MD5:

    PowerShell
    Get-FileHash "C:\Downloads\app.zip" -Algorithm MD5

    Want just the hash string, with no table? Reach into the object's .Hash property:

    PowerShell
    (Get-FileHash "C:\Downloads\app.zip").Hash

    Verify a download against a published checksum

    This is the everyday job: a project lists a SHA-256 next to its installer, and you want to confirm the file you got matches. Compare the computed hash to the published one with -eq:

    PowerShell
    (Get-FileHash ".\app.zip").Hash -eq '9F86D081884C7D659A2FEAA0C55AD015A3BF4F1B2B0B822CD15D6C15B0F00A08'
    True

    True means the file is intact. PowerShell's string -eq is case-insensitive, so it doesn't matter whether the site published the hash in upper or lower case. If you get False, the usual culprits are a partial download, the wrong algorithm, or stray whitespace pasted with the expected value.

    Compare two files by hash

    To prove two files are byte-for-byte identical — a copy versus its original, say — hash both and compare. This is far more trustworthy than matching size or modified date, which can agree even when the bytes differ:

    PowerShell
    (Get-FileHash "D:\backup\report.pdf").Hash -eq (Get-FileHash "C:\work\report.pdf").Hash
    True

    Need to do this without a terminal, or for someone who doesn't live in PowerShell? Our free Compare Files tool does the same check in the browser, and the checksum calculator hashes a single file on the spot.

    The certutil alternative (Command Prompt)

    If you're in cmd.exe rather than PowerShell, certutil computes the same hashes. It's been in Windows for years and needs no PowerShell session:

    Command Prompt
    certutil -hashfile "C:\Downloads\app.zip" SHA256
    
    SHA256 hash of C:\Downloads\app.zip:
    9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
    CertUtil: -hashfile command completed successfully.

    Same hash, different tool. certutil prints the digest in lower case and adds two status lines, so it's a little harder to script around than Get-FileHash's clean object — but for a quick manual check it's perfectly fine.

    Hashing a whole folder

    Get-FileHash only hashes files you name, but it accepts pipeline input — so you can feed it a recursive listing and get a hash for every file under a folder:

    PowerShell
    Get-ChildItem "C:\Project" -Recurse -File | Get-FileHash -Algorithm SHA256 |
      Select-Object Hash, Path

    That prints a hash per file. You can even save it to a CSV to keep a record:

    PowerShell
    Get-ChildItem "C:\Project" -Recurse -File | Get-FileHash |
      Export-Csv "C:\baselines\project-hashes.csv" -NoTypeInformation

    Where the one-liner stops being enough

    The folder loop works, but the moment you want to verify a folder rather than just list hashes, the gaps show up fast:

    • ·No diff. Two CSV dumps don't tell you what changed. You'd have to script the comparison — and handle files that were added or deleted, not just modified.
    • ·No clean pass/fail. A scheduled task wants one exit code that says "unchanged" or "something moved." A hash dump gives you neither.
    • ·No report. When something has changed, you want a readable record of exactly which files — not a diff of two spreadsheets.
    • ·It's slow to maintain. Paths with spaces, long-path limits, and re-hashing unchanged files all become your problem.

    At that point you've started writing a folder-verification tool in PowerShell. That's the line where a purpose-built manifest pays off.

    Verify whole folders, repeatably

    The FolderManifest CLI turns the folder case into two commands. Capture a SHA-256 baseline of the folder once, when you know it's good:

    PowerShell
    foldermanifest generate "C:\Project" --format json --out project-baseline

    Then verify against that baseline any time — by hand, or from a scheduled task. It exits 0 when the folder matches and 1 when any file was added, removed, or modified, so it drops straight into a script:

    PowerShell
    foldermanifest verify "C:\Project" --manifest project-baseline.json
    if ($LASTEXITCODE -eq 0) { "OK: unchanged" } else { "DRIFT: review the report" }

    That's the whole difference: Get-FileHash answers "is this file intact right now?", while a manifest answers "is this whole folder exactly as I left it?" — with a diff, a report, and a single exit code you can schedule. To put it on a timer, see automating folder verification with Task Scheduler, and for the hash trade-offs behind all of this, read MD5 vs SHA-256.

    From one file to the whole folder

    The FolderManifest CLI ships inside the desktop app on Windows and Linux — included with the 7-day trial and every lifetime license. Hash one file in PowerShell; verify the whole folder with one command.

    Frequently asked questions

    How do I get the SHA-256 hash of a file in PowerShell?
    Run Get-FileHash followed by the path, for example Get-FileHash "C:\Downloads\app.zip". Get-FileHash uses SHA-256 by default and prints the Algorithm, Hash, and Path. Add -Algorithm MD5 or -Algorithm SHA1 to use a different algorithm.
    How do I compare a file against a published checksum in PowerShell?
    Capture the hash and compare it to the expected value: (Get-FileHash .\app.zip).Hash -eq 'ABC123...'. PowerShell string comparison with -eq is case-insensitive, so it matches whether the published hash is upper or lower case. It returns True when the file is intact.
    How do I compare two files by hash in PowerShell?
    Hash both and compare: (Get-FileHash a.iso).Hash -eq (Get-FileHash b.iso).Hash. True means the files are byte-for-byte identical. This is more reliable than comparing file size or modified date, which can match even when contents differ.
    Can Get-FileHash hash an entire folder?
    Not directly — it hashes individual files. You can pipe a recursive listing into it: Get-ChildItem -Recurse -File | Get-FileHash. That prints one hash per file, but it does not save a baseline, diff against a previous run, or tell you which files were added or removed. For repeatable folder verification, generate a manifest once and verify against it.
    What is the difference between Get-FileHash and certutil?
    Both compute file hashes on Windows. Get-FileHash is the modern PowerShell cmdlet and is easiest to script. certutil -hashfile file SHA256 is the older Command Prompt equivalent and is handy when PowerShell is unavailable. They produce the same hash for the same file and algorithm.
    Is MD5 or SHA-256 better for verifying a download?
    Use SHA-256. MD5 is faster but cryptographically broken, so a malicious file can be crafted to match a given MD5. SHA-256 has no practical collision attack and is the safe default for verifying downloads and artifacts. See our MD5 vs SHA-256 comparison for the full picture.
    Why does Get-FileHash return a different hash than the website lists?
    The most common causes are a partial or corrupted download, comparing against the wrong algorithm (MD5 vs SHA-256), or hidden whitespace when you pasted the expected hash. Re-download, confirm the algorithm matches, and trim the pasted value before comparing.
    How can I verify a whole folder of files at once on Windows?
    Generate a SHA-256 baseline manifest of the folder once with the FolderManifest CLI, then run verify against it whenever you want to confirm nothing changed. verify exits 0 when the folder matches and 1 when any file was added, removed, or modified — so it works in scripts and scheduled tasks, which a per-file Get-FileHash loop cannot do cleanly.

    Related: MD5 vs SHA-256 · sha256sum & md5sum on Linux · Automate folder verification