- This topic has 1 reply, 2 voices, and was last updated 3 weeks, 6 days ago by
September 26, 2020 at 12:02 am #259063ParticipantTopics: 1Replies: 0Points: 13Rank: 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.
September 29, 2020 at 6:43 pm #259885ParticipantTopics: 0Replies: 47Points: 448Rank: Contributor
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.
Hope that helps.
- You must be logged in to reply to this topic.