r/PowerShell • u/DiskBytes • Dec 07 '25
Question sha256 with Powershell - comparing all files
Hello, if I use
Get-ChildItem "." -File -Recurse -Name | Foreach-Object { Get-FileHash -Path $($_) -Algorithm SHA256 } | Format-Table -AutoSize | Out-File -FilePath sha256.txt -Width 300
I can get the checksums of all files in a folder and have them saved to a text file. I've been playing around with it, but I can't seem to find a way where I could automate the process of then verifying the checksums of all of those files again, against the checksums saved in the text file. Wondering if anyone can give me some pointers, thanks.
11
Upvotes
View all comments
Show parent comment
1
u/BlackV Dec 08 '25
-NoTypeInformationis forexport-csvnotOut-Filethat's why you break it down into bits, run each command 1 at a time
$FilePath = '<some path>', Confirm what that returns by typing$FilePath, if that's empty or wrong step 2 would fail$HashFiles = Get-ChildItem -File -Path $FilePath | Get-FileHash -Algorithm SHA256, confirm what that returns, if that's empty or wrong, validate the path$HashFilesis valid then$HashFiles | Export-Csv -Path $FilePath\HashExport.csv -NoTypeInformationwill runnotepad $FilePath\HashExport.csvwill open the CSV