Scripting >> Powershell >> How to generate the checksum (hash) of a file

Examples

PS C:\temp> get-filehash .\mydocument.docx 

Algorithm       Hash                                                           
---------       ----                                                           
SHA256          40510F2FBD0B386589E4E6649EA9D4DDDC6406FC84C441261082DC7BE7C4...



PS C:\temp> get-filehash .\mydocument.docx -Algorithm SHA512

Algorithm       Hash                                                           
---------       ----                                                           
SHA512          D494088C1349D6BC26D50F4AC6EEBD8F05F704ACA3E0B9387BC8ECBBF4E1...


SYNTAX
    Get-FileHash [-Path] <string[]> [-Algorithm {SHA1 | SHA256 | SHA384 | SHA512 | 
    MACTripleDES | MD5 | RIPEMD160}]  [<CommonParameters>]
    
    Get-FileHash -LiteralPath <string[]> [-Algorithm {SHA1 | SHA256 | SHA384 | 
    SHA512 | MACTripleDES | MD5 | RIPEMD160}]  [<CommonParameters>]
    
    Get-FileHash -InputStream <Stream> [-Algorithm {SHA1 | SHA256 | SHA384 | 
    SHA512 | MACTripleDES | MD5 | RIPEMD160}]  [<CommonParameters>]