document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. # code from http://aperturescience.su
  2.  
  3. # Enum HashFunction
  4. #               Contains possible hash functions to choose from
  5. #
  6.  
  7. Add-Type -TypeDefinition @"
  8.        public enum HashFunction
  9.        {
  10.                sha1,
  11.                sha256,
  12.                sha384,
  13.                sha512,
  14.                md5,
  15.                ripemd160
  16.        }
  17. "@
  18.  
  19. Function Get-FileHash
  20. {
  21. [CMDLetBinding()]
  22. param
  23. (
  24.   [Parameter(mandatory=$true, valuefrompipeline=$true)] [String] $File,
  25.   [HashFunction] $HashAlgorithm = "sha256",
  26.   [switch] $Group
  27. )
  28. Process
  29. {
  30.         #check file exists, otherwise throw error
  31.         if (! (Test-Path $file))
  32.         {
  33.                 throw "Could not find file $file"
  34.         }
  35.  ...
');