Skip to content

Instantly share code, notes, and snippets.

@jbollman7
Created April 1, 2022 20:05
Show Gist options
  • Save jbollman7/3e671f808586107fe13d2c1080847a73 to your computer and use it in GitHub Desktop.
Save jbollman7/3e671f808586107fe13d2c1080847a73 to your computer and use it in GitHub Desktop.
[Windows] Get checksums of all files in a directory
$folderPath = get-childitem -path "C:\Program Files (x86)\Mortgage Cadence\Binaries";
$csvOutputName = "C:\Users\joseph.bollman\Documents\test-.csv";
#make a hash table adn then export hash table at the end?
$fileHashtable = @{}
foreach ($file in $folderPath)
{
$temp = certutil -hashfile $file.Name MD5
$value = $temp[1] -replace '\s+', '' #remove whitespace in hash found in < 2016
$fileHashtable.Add($file, $value)
}
[PSCustomObject]$fileHashtable.GetEnumerator() | Sort-Object -Property Name | Select-Object Name, Value |export-csv -Path $csvOutputName -NoTypeInformation -verbose
#$fileHashtable.GetEnumerator() | Sort-Object -Property Name | Select-Object Name, Value |export-csv -Path $csvOutputName -NoTypeInformation -verbose
# without [PSCUSTOM[ Header you will not get any values specified
#$fileHashtable | Sort-Object -Property Name | Select-Object Name, Value |export-csv -Path $csvOutputName -NoTypeInformation -verbose
# without the enumerator, you will get Nothing in the csv other than name, and value
#[PSCustomObject]$fileHashtable.GetEnumerator() |export-csv -Path $csvOutputName -NoTypeInformation -verbose
# without the sort or select, the name(alias for key) key and value shows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment