Skip to content

Instantly share code, notes, and snippets.

@jfalava
Last active January 29, 2024 11:46
Show Gist options
  • Save jfalava/ebdccb80d0814d42f0a1f37a3b053d34 to your computer and use it in GitHub Desktop.
Save jfalava/ebdccb80d0814d42f0a1f37a3b053d34 to your computer and use it in GitHub Desktop.
PowerShell script to calculate the hash of all files with an specific extension in a folder and returns it neatly into a .txt file.
$folderPath = "path\to\folder"
$outputFilePath = "path\to\txt\file\hash.txt"
$scanFiles = Get-ChildItem -Path $folderPath -Filter "*.extension"
$hashes = foreach ($file in $scanFiles) {
$hash = Get-FileHash -Path $file.FullName -Algorithm SHA256
[PSCustomObject]@{
FileName = $file.Name
Hash = $hash.Hash
}
}
$hashes | Export-Csv -Path $outputFilePath -NoTypeInformation -Delimiter "`t" -Encoding UTF8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment