Trouble creating a hash comparison script

Welcome Forums General PowerShell Q&A Trouble creating a hash comparison script

Viewing 1 reply thread
  • Author
    • #259063
      Topics: 1
      Replies: 0
      Points: 13
      Rank: Member

      I am trying to create a PS script that compares the hash of a file after download to ensure integrity. I want to make it user friendly, something I can stick in our RMM tool set so lower tier technicians can utilize it. I originally wanted to create variables like:

      $1 = SHA1
      $2 = SHA256
      $3 = SHA384
      $4 = SHA512
      $5 = MD5

      but I get the following message:

      The term ‘SHA1’ is not recognized as the name of a cmdlet, function,
      | script file, or operable program. Check the spelling of the name, or
      | if a path was included, verify that the path is correct and try again.

      When I try the variable as a string

      $1 = “SHA1”
      $2 = “SHA256”
      $3 = “SHA384”
      $4 = “SHA512”
      $5 = “MD5”
      There is no error message. I figured this is because I am trying to define something already defined, or alpha numeric variables are not allowed. I am not asking for this to be done for me, just to be pointed in the right direction so I can accomplish the following actions:
      • User is prompted for a value 1-5, each representing an Algorithm
      • User provides file path
      • User inserts hash comparison
      • User is presented with a Boolean value stating if there is a match or not


      I am an aspiring DevOps IT, I am admittedly new to robust scripting but I catch on quick. I have some experience programming with full stack environments. Any advise would be greatly appreciated.

      • This topic was modified 1 month ago by NinemmRx.
    • #259885
      Topics: 0
      Replies: 47
      Points: 448
      Helping Hand
      Rank: Contributor

      Hello NinemmRx,

      When you are initializing variables the 1st time PowerShell treats values after = as cmdlets not variable values. The error message states exactly that.

      When you are doing it 2nd time you are initializing 5 string variables.

      Reference: about_Variables

      Hope that helps.


Viewing 1 reply thread
  • You must be logged in to reply to this topic.