Powershell Menu with Sub Menu Options

Hi All

So recently I have been breaking my teeth with Powershell and creating a number of scripts which required a Menu with Sub Menu options. After a lot of trial/error and assistance from one of the most clued up Powershell gurus who is also an Office Server and Services MVP Pat Richard. I have finally got my script where it needs to be and would like to share the configuration output for those looking getting into Powershell Menus.

Examples of web services url are shown below

$Quit = ‘Q’

[string] $Menu = @’

By Andrew J. Price (Office Servers and Services MVP)

|             ## Use at your own risk ##                    |

1) Get-CsService

2) Sub Menu

Q) Quit

Select an option.. [1-99]?


[string] $Option1 = @’

│ Sub Menu Options   │

Please follow the below steps carefully as we are going to run through all the steps

required to Sub Menu

1) Command 1

2) Command 2

3) Command 3

Press enter to continue


Do {

$MenuOption = Read-Host $Menu

switch ($MenuOption){

1 { Get-CsService }

2 {

Do {

$SubMenu1 = Read-Host $Option1

switch ($Option1){

1 { Get-CsService }

2 {Get-CsService }

3 { Get-CsService}



until ($Menu -notmatch {$Quit})


$Quit {return}


} until ($Menu -notmatch {$Quit})

Hopefully article will help the next people looking at creating Powershell scripts.


Andrew J. Price – Office Servers and Services MVP