The below command will print out a list of string
Invoke-Expression -Command "mc.exe admin policy list $target" -OutVariable policiesList | Out-Null
In the powershell script, there is a prompt to enter some value
$option = Read-Host -Prompt "Enter option: "
I wanted to keep prompting the "Read-Host" to capture user value until the value (in $option ) matches in the policiesList. I have tried using the IndexOf, but it returns -1 even though the $option matches one of the value in policiesList
$rr=[array]::IndexOf($policiesList , $option)
echo $rr
The below is my entire script
Invoke-Expression -Command "mc.exe admin policy list $target" -OutVariable policiesList | Out-Null
$option=""
$i=[Array]::IndexOf($policiesList, $option)
while($i -eq -1){
$i=[Array]::IndexOf($policiesList, $option)
$option = Read-Host -Prompt "Enter option"
}