0

I have this requirement:

ListItem
--------
ABV
DEF
GED
ZAF

NOTE: ListItem is from an output of process one at a time.

foreach ($list in $listItem)
{  # Want to turn this into single row as each item get loaded
  ABV,DEF,GED,ZAF
} 

What I have done to solve this is to land this entries into file first before processing with the code below

$list = Get-Content -Path C:\Ftest
[string]::Join(',' , $list) | Set-Content -Path C:\FFtestFinal

What I cannot figure out is how to build the list without landing it in a file. I want to land it directory in C:\FFtestFinal with the values ABV,DEF,GED,ZAF.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
  • Are you asking "how to take multiple lines of output from a function and pass it as one line to another"? If so then [this](https://stackoverflow.com/a/36428950/4499969) answer may be of use to you. – unDeadHerbs Sep 27 '17 at 02:41
  • Are you looking for `(... | Select-Object -Expand ListItem) -join ','`? – Ansgar Wiechers Sep 27 '17 at 09:45

1 Answers1

0

Try something like this:

$YourInput = 'ABV','DEF','GED','ZAF'
$YourInput -join ';'

Or (overall idea):

(Get-ChildItem -Filter '*.*' | Select-Object -ExpandProperty Name) -join ';'
atorres
  • 11
  • 4