Advertisement
Guest User

Untitled

a guest
Apr 11th, 2015
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. try {
  2.     # open the hashes file
  3.     $reader = [System.IO.File]::OpenText("hashes.txt")
  4.  
  5.     # first line is the file path
  6.     $filePath = $reader.ReadLine();
  7.     while ($filePath -ne $null) {
  8.         [Console]::Out.Write($filePath + " ... ")
  9.  
  10.         $actualHash = Get-FileHash $filePath
  11.         $actualHash = $actualHash.Hash
  12.        
  13.         # next line is just the size, which we don't care about
  14.         $ignore = $reader.ReadLine();
  15.  
  16.         # next line is the real hash
  17.         $realHash = $reader.ReadLine();
  18.         if ($realhash -eq $actualHash) {
  19.             "OK!"
  20.         }
  21.         else
  22.         {
  23.             "No!"
  24.             "`tExpected: [" + $realHash + "]"
  25.             "`tActual  : [" + $actualHash + "]"
  26.         }
  27.  
  28.         # move on to the next file
  29.         $filePath = $reader.ReadLine()
  30.     }
  31. }
  32. catch
  33. {
  34.     $_
  35. }
  36. finally {
  37.     $reader.close()
  38.     "Done!"
  39.     pause
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement