Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

PowerShell Multiple Choice Menu

$
0
0

Building further on menu script that Bill_Stewart posted @ below link; Taking that as example, I want to tweak it so that I can select 'A' AND 'C' (more than one) choices and script should run BOTH functions/commands, either one after other or simultaneously. Is there a way?


**************************
do {
  do {
    write-host ""
    write-host "A - Selection A"
    write-host "B - Selection B"
    write-host "C - Selection C"
    write-host "D - Selection C"
    write-host ""
    write-host "X - Exit"
    write-host ""
    write-host -nonewline "Type your choice and press Enter: "
    $choice = read-host
    write-host ""
    $ok = @("A","B","C","D","X") -contains $choice
    if ( -not $ok) { write-host "Invalid selection" }
  }
  until ( $ok )
  switch ( $choice ) {
    "A" {
      write-host "You entered 'A'"
      break
    }
    "B" {
      write-host "You entered 'B'"
      break
    }
    "C" {
      write-host "You entered 'C'"
      break
    }
    "D" {
      write-host "You entered 'D'"
      break
    }
  }
}
until ( $choice -eq "X" )
**************************

Source: http://social.technet.microsoft.com/Forums/scriptcenter/en-US/737af85d-2681-450f-95cb-8afbd905684b/newbie-to-powershell-need-help-creating-a-menu


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>