I'm struggling with to get the same Read-Host if the user put in an invalid input. I have tried many different solution but can't get it to work.
My example is a simple yes/no script. But I want it to give me the Read-Host again if it's not ja/nej. I'ts also okay to get a more universal solution, like if wrong input tray again kind of way.
Write-Host "Er du født før 1. januar 2000?";
$Readhost = Read-Host "ja/nej"
switch ($Readhost)
{
ja {write-host "Så er du over 18 år gammel"}
nej {write-host "Så er du yngere end 18 år"}
default {write-host ”Svar på spørgsmålet!”}
}
