I was having difficulty understanding how String values work with arrays in powershell. I wanted to know the correct syntax for placing an array into a string. Currently, this is what I am trying. The square brackets seem to be registered as part of the string rather than the variable.
$array = @(2,3,5)
$string = " I have $array[2] apples"
This outputs: I have 2 3 5[2] apples
-foperator; e.g.:"I have {0} apples" -f $array[2]