Reputation: 117
I have an array of numbers (larger than the example)
$ccheck = ("44729375","74729375")
for ( $i = 0; $i -lt $ccheck.Count; $i++ ) {
cd $env:userprofile\desktop\CURL\
$ccheck[$i]
$curlexec ="curl -L ""https://server.net/$ccheck[$i]""";
$curlexec
}
with a for loop I am iterating over an array. When asking for index with $ccheck[$i]
I am getting the first index which is 44729375
. But from $curlexec
variable I am getting the whole array and I just want the i index.
So I am getting this as as output https://server.net/44729375 74729375
from the variable $curlexec
. I don't know what's wrong.
Upvotes: 0
Views: 55
Reputation: 30238
Read Get-Help 'about_Quoting_Rules'
.
Use either sub-expression syntax
$curlexec ="curl -L ""https://server.net/$($ccheck[$i])""";
##### note the change $( )
or an auxiliary variable
$ccheckaux = $ccheck[$i]
$curlexec ="curl -L ""https://server.net/$ccheckaux""";
Upvotes: 3