Link to home
Start Free TrialLog in
Avatar of thaapavuori
thaapavuoriFlag for Finland

asked on

powershell and if statement

I have made this kind of PS script. What is wrong with it?

Depending of variable $type I would like to set value of variable $value. What is wrong with this and how I could correct it?

$type = Read-Host "Write the type"
   if ($type -eq 1) {$value -eq "A"}
     elseif ($type -eq 2) {$value -eq "B"}
     elseif ($type -eq 3) {$value -eq "C"}
     else {"You typed incorrectly"}


Kind regards,
Timo
ASKER CERTIFIED SOLUTION
Avatar of soostibi
soostibi
Flag of Hungary image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
your using the comparison operator eq to do the assignment - try this

$type = Read-Host "Write the type"
   if ($type -eq 1) {$value = "A"}
     elseif ($type -eq 2) {$value = "B"}
     elseif ($type -eq 3) {$value = "C"}
     else {"You typed incorrectly"}

Open in new window