thaapavuori
asked on
While loop and powershell
I have made a loop like this
$end = Read-Host "Type"
if ($end -eq 1)
{
Funtion1
}
elseif ($end -eq 2)
{
Function2
}
else
{Write-Host "The end"}
} while ($end -eq 1)
My problem is that now this loop is working when i type number 1. But it should work with 1 and 2. -gt is is not an option because user might type also something else than text there. Im very new with PS but this cant be very difficult.
Thanks in advance :)
Timo
$end = Read-Host "Type"
if ($end -eq 1)
{
Funtion1
}
elseif ($end -eq 2)
{
Function2
}
else
{Write-Host "The end"}
} while ($end -eq 1)
My problem is that now this loop is working when i type number 1. But it should work with 1 and 2. -gt is is not an option because user might type also something else than text there. Im very new with PS but this cant be very difficult.
Thanks in advance :)
Timo
ASKER
It was my typo. There is "do" in my real script. The problem is that this loop will continue forever as it should if I type 1 but it should continue also if I type 2. Now this loop will stop after one circle if I type 2.
Thanks.
Timo
Thanks.
Timo
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
do{
$end = Read-Host "Type"
if ($end -eq 1)
{
Funtion1
}
elseif ($end -eq 2)
{
Function2
}
else
{Write-Host "The end"}
} while ($end -eq 1)