kjacobsen icon

get-filehash-revised

kjacobsen | PRO | 02/09/13 10:32:04 AM UTC | 0 ⭐ | 491 👁️ | Never ⏰ | []
PowerShell |

720 B

|

None

|

0 👍

/

0 👎

# code from http://aperturescience.su
 
# Enum HashFunction
#               Contains possible hash functions to choose from
#
 
Add-Type -TypeDefinition @"
        public enum HashFunction
        {
                sha1,
                sha256,
                sha384,
                sha512,
                md5,
                ripemd160
        }
"@
 
Function Get-FileHash
{
[CMDLetBinding()]
param
(
  [Parameter(mandatory=$true, valuefrompipeline=$true)] [String] $File,
  [HashFunction] $HashAlgorithm = "sha256",
  [switch] $Group
)
Process
{
        #check file exists, otherwise throw error
        if (! (Test-Path $file))
        {
                throw "Could not find file $file"
        }
 ...

Comments