Hey people
I have written a powershell script, it has a menu system, that goes to a sub menu. and i in the sub menu,
I want one of the options to be back to main menu. How can i achieve this. or a command i can use to do this, or go back to a specific part of the script
script is
# PowerShell console window Style
$pshost = get-host
$pswindow = $pshost.ui.rawui
$newsize = $pswindow.buffersize
if($newsize.height){
$newsize.height = 3000
$newsize.width = 150
$pswindow.buffersize = $newsize
}
$newsize = $pswindow.windowsize
if($newsize.height){
$newsize.height = 50
$newsize.width = 150
$pswindow.windowsize = $newsize
}
# MAIN Menu system
$Loop = $true
While ($Loop)
{
write-host
write-host
' 1) go to menu1'
write-host
' 2) go to menu 2'
write-host
' 3) exit'
$opt = Read-Host "Select an option [0-3]"
write-host $opt
switch ($opt)
"1" {
$Loop = $true
While ($Loop)
{ write-host
write-host
' 1) script 1'
write-host
' 2) script 2'
write-host
' 3) script 3'
write-host
' 4) script 4 '
write-host
' 5) script 5 '
write-host
' 6) back to Main Menu'
write-host
$opt = Read-Host "Select an option [0-6]"
write-host $opt
switch ($opt)
"1" { #script}
"2" { #script}
"3" { #script# }
"4" {#script }
"5" {#script #}
"6" {???????????}
default {"$_ is an invalid choice"}
}
}
}
"3" {Exit }
default {"$_ is an invalid choice"}
}
}