So I'm trying to make a script on PowerShell where It asks me if I want to access a list of 3 websites and then ask what browser I would like to use, whether it be google chrome or IE.. I know the script that I will be using which is [System.Diagnostics.Process]::Start("chrome.exe","http://www.google.com") and ixplore.exe for the IE part.. But it just ends up giving me and error saying the index is missing and there was an unexpected token.. What am I doing wrong here? Here is a part of my code:
#Now I added menu 2 to the script by using a switch
Switch ($xMenu1){ #Second Menu appears
1 {
while ( $xMenu2 -lt 1 -or $xMenu2 -gt 4 ){
CLS
# Menu option appears
Write-Host "`t Select the browser you would like to open this website with" -Fore Cyan
Write-Host "`t 1. Google Chrome" -Fore Cyan
Write-Host "`t 2. IE" -Fore Cyan
Write-Host "`t 3. Go to Main Menu" -Fore Cyan
[int]$xMenu2 = Read-Host "`t`tEnter Menu Option Number"
#The start-Sleep indicates how long the error message starts and disappears
if( $xMenu2 -lt 1 -or $xMenu2 -gt 4 ){
Write-Host "'t error, the number you entered was not part of the menu" -Fore Red;start-Sleep -Seconds 3
}
}
Switch ($xMenu2){
1{ ""[System.Diagnostics.Process]::Start("chrome.exe","http://www.google.com")"" }
2{ "[System.Diagnostics.Process]::Start("iexplore.exe","http://www.google.com")" }
}
Aucun commentaire:
Enregistrer un commentaire