Jul 26 2021 08:04 AM
Hi,
I have started a new script for a routine task (checking resource meeting settings). The menu appears fine, but I am now not at all sure how to complete the script.
Jul 28 2021 02:02 PM
@coxygt Use the switch statement.
switch($action)
{
1 { # code goes here }
2 { # code }
default { # catch all }
}
Jul 28 2021 02:10 PM
Solution@nless you need the do/while loops I'd throw it away ...
$menu = @"
********************** Resource Calendar Delegate Booking Settings *********************
* *
* 1.Change delegate booking to Automatic *
* 2.Change delegate booking to Manual *
* 3.Check another resource calendar *
* 4.Quit *
* *
****************************************************************************************
"@
Write-Host $menu -ForegroundColor Yellow
$action = Read-Host 'Please choose the action to continue'
switch($action)
{
1 { # code goes here }
2 { # code }
3 { # code }
default { exit # catch all }
}
Jul 30 2021 07:32 AM
@psophos Thanks so much for the response, this has got it sorted.
Jul 28 2021 02:10 PM
Solution@nless you need the do/while loops I'd throw it away ...
$menu = @"
********************** Resource Calendar Delegate Booking Settings *********************
* *
* 1.Change delegate booking to Automatic *
* 2.Change delegate booking to Manual *
* 3.Check another resource calendar *
* 4.Quit *
* *
****************************************************************************************
"@
Write-Host $menu -ForegroundColor Yellow
$action = Read-Host 'Please choose the action to continue'
switch($action)
{
1 { # code goes here }
2 { # code }
3 { # code }
default { exit # catch all }
}