How do I use nested Label with nested Switch in Powershell?

Hi,
I am trying to run the script with Label and Switch in Menu format so that the main module calls the submodule and ends in the submodule. The submodule should be able to call another module.
Please correct the script, as I think I am going wrong
Do { Write-Host " ----------MENU A----------
1 = option 1
2 = Option 2
3 = Option 3
$choice1 = read-host -prompt "Select number & press enter" }
until ($choice1 -eq "1" -or $choice1 -eq "2" -or $choice1 -eq "3")
Switch ($choice1)
    { "1" break :module1
      "2" break :module2
      "3" break :module3
module1
    Do { Write-Host " ----------MENU B----------
    1 = option 1
    2 = Option 2
    $choice2 = read-host -prompt "Select number & press enter" }
    until ($choice2 -eq "1" -or $choice2 -eq "2")
    Switch ($choice2)
    { write "Module 2"
      "1" break :module2
      "2" break :module3
module2
    Do { Write-Host " ----------MENU C----------
    1 = option 1
    $choice3 = read-host -prompt "Select number & press enter" }
    until ($choice3 -eq "1")
    Switch ($choice3)
    { write "Module 3"
      "1" break :module2
Tirtha Chandan Tripathy

Hi Tirtha,
What you want to do in PowerShell is separate elements of logic trees into individual functions. I rewrote your script attempt somewhat to show you how to do this:
function Show-MenuMain
Do
Write-Host @"
----------MENU A----------
1 = option 1
2 = Option 2
3 = Option 3
$Choice = read-host -prompt "Select number & press enter"
until ($Choice -eq "1" -or $Choice -eq "2" -or $Choice -eq "3")
Switch ($Choice)
"1" { Show-MenuModule1 }
"2" { Show-MenuModule2 }
"3" { Show-MenuModule3 }
function Show-MenuModule1
Do
Write-Host @"
----------MENU B----------
1 = option 1
2 = Option 2
$Choice = read-host -prompt "Select number & press enter"
until ($Choice -eq "1" -or $Choice -eq "2")
Switch ($Choice)
"1" { Show-MenuModule2 }
"2" { Show-MenuModule3 }
function Show-MenuModule2
Do
Write-Host @"
----------MENU C----------
1 = option 1
$Choice = read-host -prompt "Select number & press enter"
until ($Choice -eq "1")
Switch ($Choice)
"1" { Show-MenuModule1 }
Show-MenuMain
I know, this really only prepares the path to a host of new questions, more than answering your current ones, but it gives you something to work with and build upon.
Cheers,
Fred
There's no place like 127.0.0.1

Similar Messages

  • How to set the screen size with nested Iview screen

    Can someone show me how to set the screen size with nested IView  screen.
    at the moment i only try it with trial and error untill it looks somewhat close. Is there a property in VC to set the size for Height and width.
    The same question is for the form. the form elements inside the form is easy but the actual form is still a challenge.

    Hi,
    Yes you are correct ,Still the Form and iview are not able to change thier Layout Structure using a Propery.
    it is available with VC7.1
    Govindu

  • How do I use my ipad with Apple TV?

    How do i use my iPad2 with Apple TV?

    If it's an ATV2 or 3, you can use AirPlay. AirPlay automatically becomes available when the two devices are on the same Wi-Fi network.
    HOWEVER! You should be aware of that AirPlay is, in some circumstances, far inferior to VGA / HDMI-cabled solutions. Please see my posts at https://discussions.apple.com/message/18697551?ac_cid=sa123456#18697551 for more info.

  • How do I use apple remote with iPhone 5 ?

    How do I use apple remote with iPhone 5 ?

    Iphones dont have ir at all which the remote use for comm
    Only option is to use a dock which have ir

  • When I try to sign in to iTunes, it tells me that my Apple ID has not yet been used with the iTunes Store. How do I use my account with the iTunes Store?

    When I try to sign in to iTunes, it tells me that my Apple ID has not yet been used with the iTunes Store. How do I use my account with the iTunes Store?

    Hello Daijalove97,
    Thanks for using Apple Support Communities.
    For more information on this, take a look at:
    Using an existing Apple ID with the iTunes Store and Mac App Store
    http://support.apple.com/kb/HT2589
    To use your Apple ID at the iTunes Store
    Open the latest version of iTunes.
    Choose Store > Sign In from the Store menu.
    Enter your Apple ID and password, then click Sign In.
    Click Review when asked to review your information.
    Enter your billing information, a credit card will be required.
    Click Continue when you're done entering your credit card and billing information.
    Best of luck,
    Mario

  • How can I use an iPad with two itunes accounts?

    How can I use an iPad with two itunes accounts?
    Hi there
    My partner has a works iPad, which has her works Apps on (ones that are specifically made by her company and are NOT available in the App store).
    What I want to be able to do is to ALSO have my itunes account on there so that I can put all the apps I have purchased previously from my iPhone on it.
    This is so I can put on VLC player (thats already in my itunes account) so I can add videos to the iPad.
    How do I do this please?
    I tried it before by connecting it to my mac, but it wiped everything off the iPad completely and also deleted the data settings for using 3G.
    So I want to avoid this happening again the future as it had to be sent back to her head office to be sorted again.
    Any advise please?
    Thanks

    You can't. The iPad is desgined to be a 'one user' device and only really works with one apple ID at a time.
    The only way would be if she, at work and with her work apple id, downloaded your apps (repurchasing them of course).
    It's not meant to be a multiple user/multiple ID device.

  • How can i use text expander with the new Mavericks,

    how can i use text expander with the new Mavericks,

    I regret upgrading to mavericks for the same reason
    ftamez wrote:
    how can i use text expander with the new Mavericks,
    Now I have been searching - and you have to buy an app and it will cost you $34.99 (what a rip off)

  • TS1629 How do I use home sharing with direct TV / Verizon internet. I have turned on Home sharing on apple tv and in iTunes but can't see the library in apple tv. I can see the photo stream but thats it. Any Ideas????

    How do I use home sharing with direct TV / Verizon internet. I have turned on Home sharing on apple tv and in iTunes but can't see the library in apple tv. I can see the photo stream but thats it. Any Ideas????

    go to home-sharing on Apple TV and type in your info as ask.
    hope this help

  • How do I use Home Sharing with two different apple accounts?

    How do I use Home Sharing with two different apple accounts?

    Morning Saintine,
    Thanks for using Apple Support Communities.
    Home Sharing enables you to stream or transfer music, movies, TV shows, apps, and more among up to five authorized computers in your household. To do so, you will need to Turn on Home Sharing on each computer using the same Apple ID.
    Understanding Home Sharing
    http://support.apple.com/kb/HT3819
    Hope this helps,
    Mario

  • How do i use itunes server with itunes match?

    Hi all,
    I am using itunes server on my synology NAS. On my desktop i've always used itunes with match. How can I combine the two? In other words, how can i use itunes match with itunes server?
    thanx

    I don't know if you've already solved it yourself, but I had this problem too. Try signing out of iTunes Store under 'Settings', then signing back in with JUST your iTunes user name, with no '.mac' or '.me' suffix. If, for example, your usual sign-in method is '[email protected]' try using 'joebloggs'.
    Worked for me.

  • How do I use my iPad with a digital projector

    How do I use my iPad with a projector

    Have a look at this:
    http://www.epson.com/cgi-bin/Store/jsp/Landing/ProjectorApp.do

  • How do you use an iPad with Apple TV

    How do I use an iPad with Apple TV?

    Read the iPad manual:  http://support.apple.com/manuals/#ipad
    See this article: http://support.apple.com/kb/HT4437

  • How can i use "icloud backup" with ios 4.2.1?

    How can i use "icloud backup" with ios 4.2.1? I tried to update my ihpone 3G wih the newest IOs. Seems not to be possible.

    You cannot.
    It requires ios 5.
    Your iphone can only go to 4.2.1

  • How can I use the NI PXI-6508 with Lab View 7? what are the first steps to get started??How can I use the channels with lab view 7????

    I have a 8 slot PXI system with 2 NI PXI 6508 and 1 DMM 4070 in it. I want to get started with programming the digital I/O cards (6508)! How can I use this cards with LabView 7?what is the best way to get started, or where can I get examples showing how to use the several channels?
    Thanks!
    Philipp

    Philipp,
    The best way to get started is to decide if you want to use traditional NI-DAQ or NI-DAQmx. Recently we released NI-DAQ 7.1 which provides NI-DAQmx support for the PXI-6508. In my opinion, NI-DAQmx is more efficient and much easier to use.
    To get started with examples, simply launch LabVIEW and go to Help>>Find Examples. Then expand Hardware Input and Output>>DAQmx and select the appropriate digital group for your application. This should help get you started.
    Please repost if you need addition assistance. Good luck with your application!

  • How can I use the DBAdapter with SequencingPollingStrategy in OSB Cluster?

    Hi!
    I have a OSB cluster. I need to read a view with the DBAdapter. I use SequencingPollingStrategy to implement the adapter.
    Then I import it into OSB and make it work and the service works normally in the single node.
    But if I import it into OSB cluster, the service always read the duplication records from the view.(the Distrbute polling is not worked in SequencingPollingStrategy )
    So how can I use the DBAdapter with SequencingPollingStrategy in OSB Cluster?
    Thank you!

    Nope. Version 5 is a fashion accessory: it looks like software, but it doesn;t actually do anything. Sort of like a sports car with a lawn-mower engine. Looks snzzy. Doesn't really work. (And given how buggy it is, I should further specifiy that the lawn-mower engine comes with a blade: it chews up your old templates, produces files that cannot be sent as email attahcments [yes, really], and—this just in—doesn;t play well with the new SMB facility of Mavericks. In short, as one reviewer put it, "un unmitigated disaster."

Maybe you are looking for