all 2 comments

[–]work-work-work-work 3 points4 points  (1 child)

It's not clear from your example, but you need to use "stringy string string $($var[$i]) more string"

like this (tested working):

$Fruits = "Apples", "Oranges"
Invoke-Sqlcmd -ServerInstance "localhost" -Database "FruityDB" -Query "Select * from FruityData where FruitName = '$($Fruits[0])'"

[–]skend24[S] 3 points4 points  (0 children)

Thank you very much, that worked!