Why simple while loop doesn't work?

Sorry for this simply one, but can someone explain why when I enter any number between 1-5 the Get-Service doesn’t execute.

I also tired ($sel -eq “1”,“2”,“3”,“4”,“5” )



$sel = Read-Host -Prompt "Enter number 1-5"

While ($sel -eq 1,2,3,4,5 ) {

#below doesn't happen when enter 1-5 

Get-Service t* | Where-Object {$_.Status -eq "Stopped"}


1,2,3,4,5 is an array of five items. Any single item, like 1, is not equal to an array. You may want to use the -in operator instead.

While (1,2,3,4,5 -eq $sel) {

would actually work (I sort of learned this from the Iron Scripting). But do you want to keep repeating the body of the while loop over and over without asking for new input?