powershell - Power Shell script - if and switch missing statement -


i have script, worked, , it's stupid sign missing, cant find it. me please? supposed pop choice bar , change $answer according chosen project.

#what project work on $caption = "choose action"; $message = "what project testing?"; $lll = new-object system.management.automation.host.choicedescription "&lll","lll"; $jjj = new-object system.management.automation.host.choicedescription "&jjj","jjj"; $ppp = new-object system.management.automation.host.choicedescription "&ppp","ppp"; $choices = [system.management.automation.host.choicedescription[]]($lll,$jjj,$ppp); $project = $host.ui.promptforchoice($caption,$message,$choices,0)  switch ($project) {     0 {"lll"; break}     1 {"jjj"; break}     2 {"ppp"; break}     }   if ($project -eq 0)      {     $answer = "lll"      }   if ($project -eq 1)      {     $answer = "jjj"      }   if ($project -eq 2)      {     $answer = "ppp"      }   error   o.ps1:128 char:23 +     if ($project -eq 1) +                       ~ missing statement block after if ( condition ). @ ps1:136 char:27 +         if ($project -eq 2) +                           ~ missing statement block after if ( condition ).     + categoryinfo          : parsererror: (:) [], parentcontainserrorrecordexception     + fullyqualifiederrorid : missingstatementblock 

your code should work. if want set $answer, can within switch block:

$answer = switch ($project) {     0 {'lll'}     1 {'jjj'}     2 {'ppp'} } 

now can omit if statements...


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -