SOLVED

Interactive menu to choose task

%3CLINGO-SUB%20id%3D%22lingo-sub-2587260%22%20slang%3D%22en-US%22%3EInteractive%20menu%20to%20choose%20task%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2587260%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI%20have%20started%20a%20new%20script%20for%20a%20routine%20task%20(checking%20resource%20meeting%20settings).%26nbsp%3B%20The%20menu%20appears%20fine%2C%20but%20I%20am%20now%20not%20at%20all%20sure%20how%20to%20complete%20the%20script.%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3E%23Connect%26nbsp%3Bto%26nbsp%3BExchange%26nbsp%3BOnline%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24MFAExchangeModule%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3D%26nbsp%3B((%3C%2FSPAN%3E%3CSPAN%3EGet-ChildItem%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-Path%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3E%24env%3ALOCALAPPDATA%3C%2FSPAN%3E%3CSPAN%3E%2B%3C%2FSPAN%3E%3CSPAN%3E%22%5CApps%5C2.0%5C%22%3C%2FSPAN%3E%3CSPAN%3E)%26nbsp%3B-Filter%26nbsp%3BCreateExoPSSession.ps1%26nbsp%3B-Recurse%26nbsp%3B).FullName%26nbsp%3B%7C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3ESelect-Object%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-Last%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E1%3C%2FSPAN%3E%3CSPAN%3E)%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3E%24MFAExchangeModule%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24un%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3D%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3ERead-Host%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22Enter%26nbsp%3BUsername%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EConnect-EXOPSSession%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-UserPrincipalName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24un%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%23Build%26nbsp%3Ba%26nbsp%3Bmenu%26nbsp%3Bof%26nbsp%3Bchoices%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EDo%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eif%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3E%24Action%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-eq%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22%22%3C%2FSPAN%3E%3CSPAN%3E)%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eif%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3E%24Delay%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-eq%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24true%3C%2FSPAN%3E%3CSPAN%3E)%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EStart-Sleep%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-Seconds%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E2%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24Delay%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%24true%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22**********************%26nbsp%3BResource%26nbsp%3BCalendar%26nbsp%3BDelegate%26nbsp%3BBooking%26nbsp%3BSettings%26nbsp%3B*********************%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-ForegroundColor%26nbsp%3BYellow%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22*%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B*%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-foregroundcolor%26nbsp%3Byellow%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22*%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B1.Change%26nbsp%3Bdelegate%26nbsp%3Bbooking%26nbsp%3Bto%26nbsp%3BAutomatic%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B*%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-foregroundcolor%26nbsp%3Byellow%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22*%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B2.Change%26nbsp%3Bdelegate%26nbsp%3Bbooking%26nbsp%3Bto%26nbsp%3BManual%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B*%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-ForegroundColor%26nbsp%3BYellow%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22*%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B3.Check%26nbsp%3Banother%26nbsp%3Bresource%26nbsp%3Bcalendar%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B*%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-ForegroundColor%26nbsp%3BYellow%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22*%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B4.Quit%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B*%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-ForegroundColor%26nbsp%3BYellow%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22*%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B*%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-foregroundcolor%26nbsp%3Byellow%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22****************************************************************************************%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-ForegroundColor%26nbsp%3BYellow%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24i%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3D%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3ERead-Host%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E'Please%26nbsp%3Bchoose%26nbsp%3Bthe%26nbsp%3Baction%26nbsp%3Bto%26nbsp%3Bcontinue'%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%7D%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ewhile%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B(%3C%2FSPAN%3E%3CSPAN%3E%24Action%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3D%3C%2FSPAN%3E%3CSPAN%3E%22%22%3C%2FSPAN%3E%3CSPAN%3E)%26nbsp%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eelse%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24i%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%24Action%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%3CSPAN%3EBasically%2C%20choosing%20Option%201%20should%20result%20in%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3ESet-CalendarProcessing%26nbsp%3B-Identity%26nbsp%3B%24roomname%26nbsp%3B-AutomateProcessing%26nbsp%3BAutoAccept%26nbsp%3B-DeleteComments%26nbsp%3B%24true%26nbsp%3B-AddOrganizerToSubject%26nbsp%3B%24true%26nbsp%3B-AllowConflicts%26nbsp%3B%24false%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%3CSPAN%3EOption%202%20should%20result%20in%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3ESet-CalendarProcessing%26nbsp%3B-Identity%26nbsp%3B%24roomname%26nbsp%3B-AutomateProcessing%26nbsp%3BNone%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EOption%203%20should%20simply%20start%20the%20script%20again%20from%20the%20point%20of%20displaying%20the%20menu%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EOption%204%20should%20basically%20exit%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ECompletely%20stuck%2C%20any%20help%20appreciated.%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2587260%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExchange%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2594523%22%20slang%3D%22en-US%22%3ERe%3A%20Interactive%20menu%20to%20choose%20task%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2594523%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F992929%22%20target%3D%22_blank%22%3E%40coxygt%3C%2FA%3E%26nbsp%3B%20Use%20the%20%3CSTRONG%3Eswitch%3C%2FSTRONG%3E%20statement.%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3Eswitch(%24action)%0A%7B%0A%20%20%20%201%20%7B%20%23%20code%20goes%20here%20%7D%0A%20%20%20%202%20%7B%20%23%20code%20%7D%0A%20%20%20%20default%20%7B%20%23%20catch%20all%20%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

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.

#Connect to Exchange Online
$MFAExchangeModule = ((Get-ChildItem -Path $($env:LOCALAPPDATA+"\Apps\2.0\") -Filter CreateExoPSSession.ps1 -Recurse ).FullName | Select-Object -Last 1)
"$MFAExchangeModule"
$un = Read-Host "Enter Username"
Connect-EXOPSSession -UserPrincipalName $un
#Build a menu of choices
Do {
 if($Action -eq "")
 {
  if($Delay -eq $true)
  {
   Start-Sleep -Seconds 2
  }
  $Delay=$true
 Write-Host "********************** Resource Calendar Delegate Booking Settings *********************" -ForegroundColor Yellow
 Write-Host "*                                                                                      *" -foregroundcolor yellow
 Write-Host "*    1.Change delegate booking to Automatic                                            *" -foregroundcolor yellow
 Write-Host "*    2.Change delegate booking to Manual                                               *" -ForegroundColor Yellow
 Write-Host "*    3.Check another resource calendar                                                 *" -ForegroundColor Yellow
 Write-Host "*    4.Quit                                                                            *" -ForegroundColor Yellow
 Write-Host "*                                                                                      *" -foregroundcolor yellow
 Write-Host "****************************************************************************************" -ForegroundColor Yellow
 $i = Read-Host 'Please choose the action to continue' 
 }}
 while ($Action =""
 else
 {
  $i=$Action
 }
 
Basically, choosing Option 1 should result in 
Set-CalendarProcessing -Identity $roomname -AutomateProcessing AutoAccept -DeleteComments $true -AddOrganizerToSubject $true -AllowConflicts $false
Option 2 should result in 
Set-CalendarProcessing -Identity $roomname -AutomateProcessing None
Option 3 should simply start the script again from the point of displaying the menu
Option 4 should basically exit
 
Completely stuck, any help appreciated.
3 Replies

@coxygt  Use the switch statement.

switch($action)
{
    1 { # code goes here }
    2 { # code }
    default { # catch all }
}
best response confirmed by coxygt (Occasional Contributor)
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 }
}

@psophos  Thanks so much for the response, this has got it sorted.