I have an array of strings. Not sure if there is simple way to get the index of an item first found in the array?
# example array
$array = "A", "B", "C"
$item = "B"
# the following line gets null, any way to get its index?
$index = $array | where {$_ -eq $item} | ForEach-Object { $_.Index }
I could do it in a loop. not sure if there is any alternative way?