powershellget-filehash

Get-FileHash in the entire C: drive


I'm writing a script to collect all file hashes in the C: drive but doesn't grab everything. Anyone have any ideas? I tried a mix of things.

gci -Path C:\ -Recurse | Get-FileHash -Algorithm MD5 | Out-File C:\test.txt

Solution

  • # Examine $errs afterwards to see which paths couldn't be accessed.
    Get-ChildItem C:\ -Recurse -File -Force -ea SilentlyContinue -ev errs | 
      Get-FileHash -Algorithm MD5 | 
        Out-File C:\test.txt
    

    Note: The Out-File cmdlet saves the for-display representation of the command's output to a file, which isn't designed for further programmatic processing.
    To save a representation that is suitable for subsequent programmatic processing, use a cmdlet such as Export-Csv.