PowerShell Logo Small

Get-FileHash



This is the built-in help made by Microsoft for the command 'Get-FileHash', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Computes the hash value for a file by using a specified hash algorithm.

SYNTAX


Get-FileHash [-Path] <String[]> [-Algorithm <String>] [<CommonParameters>]
Get-FileHash [-Algorithm <String>] -LiteralPath <String[]> [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


Get-FileHash computes the hash value for a file by using a specified hash algorithm. A hash value is a unique value that corresponds to the content of the file. Rather than
identifying the contents of a file by its file name, extension, or other designation, a hash assigns a unique value to the contents of a file. File names and extensions can
be changed without altering the content of the file, and without changing the hash value. Similarly, the file’s content can be changed without changing the name or
extension. However, changing even a single character in the contents of a file changes the hash value of the file.


The purpose of hash values is to provide a cryptographically-secure way to verify that the contents of a file have not been changed. While some hash algorithms, including
MD5 and SHA1, are no longer considered secure against attack, the goal of a secure hash algorithm is to render it impossible to change the contents of a file—either by
accident, or by malicious or unauthorized attempt—and maintain the same hash value. You can also use hash values to determine if two different files have exactly the same
content. If the hash values of two files are identical, the contents of the files are also identical.


By default, the Get-FileHash cmdlet uses the SHA256 algorithm, although any hash algorithm that is supported by the target operating system can be used.



<

RELATED LINKS


Online Version: http://go.microsoft.com/fwlink/?LinkId=325249

REMARKS

<

Examples


Example 1

PS C:\> Get-FileHash $pshome\powershell.exe | Format-List

Algorithm : SHA256
Hash : 6A785ADC0263238DAB3EB37F4C185C8FBA7FEB5D425D034CA9864F1BE1C1B473
Path : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe



This example uses the Get-FileHash cmdlet to compute the hash value for the Powershell.exe file. The hash algorithm used is the default, SHA256. The output is piped to the
Format-List cmdlet to format the output as a list.




Example 2

PS C:\> Get-FileHash C:\Users\Andris\Downloads\Contoso8_1_ENT.iso -Algorithm SHA384 | Format-List

Algorithm : SHA384
Hash : 20AB1C2EE19FC96A7C66E33917D191A24E3CE9DAC99DB7C786ACCE31E559144FEAFC695C58E508E2EBBC9D3C96F21FA3
Path : C:\Users\Andris\Downloads\Contoso8_1_ENT.iso



This command uses the Get-FileHash cmdlet and the SHA384 algorithm to compute the hash value for an ISO file that an administrator has downloaded from the Internet. The
output is piped to the Format-List cmdlet to format the output as a list.