user1863886
user1863886

Reputation:

Do Until loop fault

do{
$ActionVariable = Read-host "Do you want to delete a folder or empty a folder ? [D/E]"
}
until($ActionVariable = "E" -or"D") 

Read-host

Hello, I am trying to write a script that lets a user choose to empty a folder or delete it as a whole. I wrote a do until loop that does not seem to function. Am I defining the until wrong ?

Upvotes: 1

Views: 6134

Answers (1)

mousio
mousio

Reputation: 10337

This should work better:
until ($ActionVariable -eq 'E' -or $ActionVariable -eq 'D')

Or perhaps this:
until ('E','D' -contains $ActionVariable)

Upvotes: 4

Related Questions