Get-ChecksumValid

Get-ChecksumValid

Get-ChecksumValid

Checks a file’s checksum versus a passed checksum and checksum type.

Syntax

Get-ChecksumValid `
  -File <String> `
  [-Checksum <String>] `
  [-ChecksumType <String>] `
  [-OriginalUrl <String>] `
  [-IgnoredArguments <Object[]>] [<CommonParameters>]

Description

Makes a determination if a file meets an expected checksum signature. This function is usually used when comparing a file that is downloaded from an official distribution point. If the checksum fails to match the expected output, this function throws an error.

Checksums have been used for years as a means of verification. A checksum hash is a unique value or signature that corresponds to the contents of a file. File names and extensions can be altered without changing the checksum signature. However if you changed the contents of the file, even one character, the checksum will be different.

Checksums are used to provide as a means of cryptographically ensuring the contents of a file have not been changed. While some cryptographic algorithms, including MD5 and SHA1, are no longer considered secure against attack, the goal of a checksum algorithm is to make it extremely difficult (near impossible with better algorithms) to alter the contents of a file (whether by accident or for malicious reasons) and still result in the same checksum signature.

When verifying a checksum using a secure algorithm, if the checksum matches the expected signature, the contents of the file are identical to what is expected.

Notes

This uses the checksum.exe tool available separately at https://community.chocolatey.org/packages/checksum.

Options that affect checksum verification:

  • --ignore-checksums - skips checksumming
  • --allow-empty-checksums - skips checksumming when the package is missing a checksum
  • --allow-empty-checksums-secure - skips checksumming when the package is missing a checksum for secure (HTTPS) locations
  • --require-checksums - requires checksums for both non-secure and secure locations
  • --download-checksum, --download-checksum-type - allows user to pass their own checksums
  • --download-checksum-x64, --download-checksum-type-x64 - allows user to pass their own checksums

Features that affect checksum verification:

  • checksumFiles - when turned off, skips checksumming
  • allowEmptyChecksums - when turned on, skips checksumming when the package is missing a checksum
  • allowEmptyChecksumsSecure - when turned on, skips checksumming when the package is missing a checksum for secure (HTTPS) locations

Aliases

None

Examples

EXAMPLE 1

Get-ChecksumValid -File $fileFullPath -CheckSum $checksum -ChecksumType $checksumType

Inputs

None

Outputs

None

Parameters

-File <String>

PropertyValue
Aliases
Required?true
Position?1
Default Value
Accept Pipeline Input?false

-Checksum [<String>]

PropertyValue
Aliases
Required?false
Position?2
Default Value
Accept Pipeline Input?false

-ChecksumType [<String>]

PropertyValue
Aliases
Required?false
Position?3
Default Valuemd5
Accept Pipeline Input?false

-OriginalUrl [<String>]

PropertyValue
Aliases
Required?false
Position?4
Default Value
Accept Pipeline Input?false

-IgnoredArguments [<Object[]>]

PropertyValue
Aliases
Required?false
Position?named
Default Value
Accept Pipeline Input?false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters http://go.microsoft.com/fwlink/p/?LinkID=113216 .

Function Reference

:choco-info: NOTE

This documentation has been automatically generated from Import-Module "$env:ChocolateyInstall\helpers\chocolateyInstaller.psm1" -Force; Get-Help Get-ChecksumValid -Full.

View the source for Get-ChecksumValid