0

I have a list of hashmaps. I want to create comma separated string for each item. If I use the following, it works fine.

$users | ForEach-Object {$_.firstname + "," + $_.surname}

But when I try to do it with string interpolation like this,

$users | ForEach-Object {"$_.firstname,$_.surname"}

It shows

System.Collections.Hashtable.firstname,System.Collections.Hashtable.surname

What mistake am I doing?

MetallicPriest
  • 29,191
  • 52
  • 200
  • 356
  • 2
    Answer to your question is here: https://stackoverflow.com/questions/1145704/how-can-you-use-an-objects-property-in-a-double-quoted-string // use `"$(....)"` for string interpolation – Santiago Squarzon Oct 29 '22 at 17:56
  • You might also have a look in here: [Does there exist a designated (sub)index delimiter?](https://stackoverflow.com/a/72793529/1701026) – iRon Oct 30 '22 at 07:47

0 Answers0