3

Im trying to generate product URL with product ID. I did a foreach loop and it works. But it puts the ID in @{}.

foreach ($ID in $id) {
    $url = "https://MyUrl/" + $ID
    $Path =  $url 
    $Path
}

The output looks like this:

https://MyUrl/@{id=351}
https://MyUrl/@{id=348}
https://MyUrl/@{id=342}
https://MyUrl/@{id=293}

How can I delete @{} from the URL, or how can I generate a product URL with (if there are any other ideas).

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Sam
  • 95
  • 1
  • 14

2 Answers2

3

Just append $ID.id:

ForEach ($ID in $id){
$url = "https://MyUrl/" +$ID.id
$Path =  $url 
$Path
}
Martin Brandl
  • 56,134
  • 13
  • 133
  • 172
2

Okay I found the solution I had to add .id after +$ID It should look like this

ForEach ($ID in $id){
$url = "https://MyUrl/"  +$ID.id
$Path =  $url 
$Path
}
Sam
  • 95
  • 1
  • 14