In this tutorial, we will show how to verify file integrity in Windows using PowerShell: calculate checksums with Get-FileHash, compare directories by hash, and detect duplicate or corrupted files.
What Is a File Hash and Why It Matters
To verify that large files, distros, or ISO images are downloaded completely, without errors, and were not modified during transition, you can check their hash. Unlike a file name or extension, a file hash (also known as a checksum) is a unique value that depends solely on the content of the file. The resulting hash can be compared to the original to verify the file’s integrity and authenticity.
In Windows, you can compute the hash value of any file without using third-party tools. You can use either the CertUtil.exe console command or the Get-FileHash PowerShell cmdlet.
How to Calculate File Hash Using PowerShell
Open the PowerShell console and specify the full path to the file whose hash you want to calculate:
Get-FileHash F:\ISO\Win_11_25H2.ISO
The SHA256 algorithm is used by default to calculate the file hash. After a while, the command will output the hash of the specified file to the screen. The time required to calculate a file hash with the Get-FileHash command depends on the fileโs size and the hashing algorithm used.

If the file’s contents change by even one character, its hash will differ the next time you check.

The Get-FileHash cmdlet lets you specify the specific cryptographic algorithm used to calculate the hash.
Supported Hashing Algorithms in PowerShell
Commonly available algorithms include:
- SHA1
- SHA256 (default)
- SHA384
- SHA512
- MD5
- MACTripleDES
- RIPEMD160
To use a specific cryptographic hash function, specify it with the -Algorithm argument:
Get-FileHash -Algorithm MD5 F:\ISO\Win_11_25H2.ISO
Note. Although MD5 is the fastest algorithm for obtaining a file checksum, it is now considered obsolete and insecure. The SHA-256 algorithm offers good performance and a low probability of collision (when two different files have the same checksum).
How to Find Duplicate Files by Hash
With PowerShell, you can quickly find duplicate files in a directory based on their content, regardless of file names or extensions:
Get-ChildItem -Recurse -File "F:\ISO" |
Get-FileHash |
Group-Object -Property Hash |
Where-Object { $_.Count -gt 1 } |
ForEach-Object { $_.Group | Select-Object Path, Hash }
In this case, we found two ISO image files with the same content.

How to Compare Directory Contents by File Hash
It is often necessary to compare the contents of two directories to ensure they are identical, such as after backing up files. This helps to ensure the backup is consistent. The easiest way to compare directory contents is by calculating and comparing the hashes of the files within them.
$SourceFolder = "C:\Data"
$TargetFolder = "F:\Data"
$FirstFolder = Get-ChildItem $SourceFolder -File -Recurse |
Select-Object *,
@{
Name="RelativePath"
Expression={$_.FullName.Substring($SourceFolder.Length)}
},
@{
Name="Hash"
Expression={(Get-FileHash $_.FullName).Hash}
}
$SecondFolder = Get-ChildItem $TargetFolder -File -Recurse |
Select-Object *,
@{
Name="RelativePath"
Expression={$_.FullName.Substring($TargetFolder.Length)}
},
@{
Name="Hash"
Expression={(Get-FileHash $_.FullName).Hash}
}
Compare-Object `
-ReferenceObject $FirstFolder `
-DifferenceObject $SecondFolder `
-Property RelativePath,Hash
This PowerShell script calculates hashes for all files in the source and destination folders, displaying only those with differing contents.

How to Verify File Integrity Against a Reference Checksum
Many developers publish checksums of their source files on their official websites to allow users to verify the fileโs integrity. The user can calculate the file’s checksum and compare it with the reference value to verify the fileโs integrity and confirm it has not been corrupted, damaged, or tampered with during download.
So, another common use case is obtaining a fileโs hash value and comparing it to the expected one.
$isoFile = "F:\ISO\Win_11_25H2.ISO" $hashFile = "F:\ISO\Win_11_25H2.hash" $computedHash = (Get-FileHash $isoFile).Hash.Trim() $expectedHash = (Get-Content $hashFile).Trim() $computedHash -eq $expectedHash
This script will return True if the file hash matches the reference value and False if they differ. This example assumes the hash file contains only the checksum value.

What is a file hash and why is it important?
A file hash (or checksum) is a unique string of characters that represents the content of a file. It helps verify that a file has not been altered, corrupted, or tampered with during download or transfer.
How can I calculate a file hash in Windows without third-party tools?
You can use PowerShellโs built-in Get-FileHash cmdlet or the CertUtil.exe console command to compute a fileโs hash.
Can I use other hashing algorithms besides SHA256?
Yes. PowerShell supports SHA1, SHA256, SHA384, SHA512, MD5, MACTripleDES, and RIPEMD160.
Whatโs the difference between CertUtil and Get-FileHash?
Both calculate hashes, but Get-FileHash is native to PowerShell and easier for scripting and automation.
