How to return to user menu at the end of a function in PowerShell -


i writing powershell script gives user number of options select from. once option selected, function executed , user returned original menu.

in code below, user given options, , functions executed, when complete, script ends. want instead @ end of function return original user menu. can tell me how this? thanks!

function firstfunction {     write-host "you chose option 1"     return }  write-host "welcome"  [int]$usermenuchoice = 0 while ( $usermenuchoice -lt 1 -or $usermenuchoice -gt 4){     write-host "1. menu option 1"     write-host "2. menu option 2"     write-host "3. menu option 3"     write-host "4. quit , exit"  [int]$usermenuchoice = read-host "please choose option"} switch ($usermenuchoice) {     1{firstfunction}     2{write-host "you chose option 2"}     3{write-host "you chose option 3"} default {write-host "nothing selected"} } 

put menu code outer loop doesn't terminate unless $usermenuchoice 4:

do {   [int]$usermenuchoice = 0   while ( $usermenuchoice -lt 1 -or $usermenuchoice -gt 4) {     write-host "1. menu option 1"     write-host "2. menu option 2"     write-host "3. menu option 3"     write-host "4. quit , exit"      [int]$usermenuchoice = read-host "please choose option"      switch ($usermenuchoice) {       1{firstfunction}       2{write-host "you chose option 2"}       3{write-host "you chose option 3"}       default {write-host "nothing selected"}     }   } } while ( $usermenuchoice -ne 4 ) 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -