17th December 2024

How to Get File Hash with PowerShell?

It is possible to obtain the Hash values ​​of a file without using an application in Windows 8, Windows 10 and higher windows operating systems. A special cmdlet allows you to calculate the SHA1, SHA256, SHA384, SHA512, MACTripleDES, MD5 and RIPEMD160 Hash values ​​of a given file. The general purpose of hashes is to ensure that the file is authentic and that its contents have not been altered by a third party, other software or malware. When a file is modified, its hash value is also changed. It is also possible to compare and match hashes to find out if two or more files are identical.

The ability to calculate the file hash is part of the Windows cryptographic API. The operating system’s user interface does not have the option to calculate or display hashes for files. You can use the “Get-FileHash” command in PowerShell instead.

You can use the following command to get the file hash with PowerShell in Windows 10.

Get-FileHash .\winmd5free.zip |Format-List

For example, we open PowerShell and write the above command. By default, it calculates the SHA256 hash value for the given file and produces the output as follows.

Get-FileHash
Get-FileHash

 

To find hashes other than SHA256, we use the Algorithm key. For example, we run the following command to get the MD5 hash.

Get-FileHash .\winmd5free.zip -Algorithm MD5 | Format-List
Get-FileHash .\winmd5free.zip -Algorithm MD5
Get-FileHash .\winmd5free.zip -Algorithm MD5

 

The list of possible values ​​for the algorithm is as follows. These;

  • MD5
  • SHA1
  • SHA256
  • SHA384
  • SHA512
  • RIPEMD160
  • MACTripleDES

Note: Another useful key to know is -LiteralPath. Specifies the path of a file. Unlike the default path parameter, the value of the LiteralPath parameter is used exactly as it is typed. No character is interpreted as a wildcard. If the path contains escape characters, enclose the path in single quotation marks. Single quotes instruct Windows PowerShell not to interpret characters as escape sequences.

LEARN MORE  What is Mikrotik Router? Mikrotik Router Configurations - DHCP Server Installation

 

Leave a Reply

Your email address will not be published. Required fields are marked *