In Powershell, how do I concatenate one property of an array of objects into a string? In Powershell, how do I concatenate one property of an array of objects into a string? powershell powershell

In Powershell, how do I concatenate one property of an array of objects into a string?


If you want an array of strings, all you have to do is to:

dir | select -expand name

If you want that as a single string with the values comma separated:

(dir | select -expand name) -join ","


Just a small improvement, you can get names only with the Name switch:

(dir -name) -join ','