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
  • 184,186
  • 23
  • 230
  • 299
Sam
  • 95
  • 1
  • 13

2 Answers2

3

Just append $ID.id:

ForEach ($ID in $id){
$url = "https://MyUrl/" +$ID.id
$Path =  $url 
$Path
}
Martin Brandl
  • 51,813
  • 12
  • 118
  • 151
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
  • 13