Last active
January 2, 2018 21:37
-
-
Save danzek/068aa9d67ddaee0eac45575e6a23a15e to your computer and use it in GitHub Desktop.
MD5 hash files in list provided in text file via PowerShell on Win7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# Public Domain. Use this however you wish! | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | |
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | |
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | |
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
#> | |
$files = Get-Content "file_path_on_each_line.txt" | |
Write-Output "File Path,MD5 Hash" | |
foreach ($f in $files) { | |
$hash = $(certUtil -hashFile $f MD5)[1] -replace " ","" | |
Write-Output "$f,$hash" | |
} | |
# or do it recursively | |
Write-Output "File Path,MD5 Hash" | |
Get-ChildItem -Recurse | where { ! $_.PSIsContainer } | | |
ForEach-Object { | |
$hash = $(certUtil -hashFile $_.FullName MD5)[1] -replace " ","" | |
Write-Output "$_,$hash" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment