-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathNew-BasicGUI.ps1
More file actions
29 lines (27 loc) · 1.09 KB
/
New-BasicGUI.ps1
File metadata and controls
29 lines (27 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$title = "Simple Menu"
$message = "What do you want to do?"
[System.Management.Automation.Host.ChoiceDescription[]]$options = @()
$options += New-Object System.Management.Automation.Host.ChoiceDescription "Option [&1]","Opt1"
$options += New-Object System.Management.Automation.Host.ChoiceDescription "Option [&2]","Opt2"
$options += New-Object System.Management.Automation.Host.ChoiceDescription "Option [&3]","Opt3"
$options += New-Object System.Management.Automation.Host.ChoiceDescription "Option [&4]","Opt4"
$result = $host.ui.PromptForChoice($title, $message, $options, 0)
switch ($result)
{
0 { # Option 1
"You selected $($options[0].HelpMessage)"
"Running commands 2,3,4"
}
1 { # Option 2
"You selected $($options[1].HelpMessage)"
"Running commmand 2"
}
2 { # Option 3
"You selected $($options[2].HelpMessage)"
"Running command 3"
}
3 { # Option 4
"You selected $($options[3].HelpMessage)"
"Running command 4"
}
}