I am working with RAW text file that I need to split and create an array. RAW Text file generated based on parameter. $list sent from another program. My Ps code:
param($list)
$path="C:\BU\test\"
New-Item $path\test.txt
Set-Content $path\test.txt "$list" --> Output RAW data Eg:(Apple Orange Kiwi)
$list2=get-Content C:\BU\test\test.txt
$cd=$list.Replace(' ',', ')
New-Item $path\cd.txt
Set-Content $path\cd.txt "$cd"
$cd=get-Content C:\BU\test\cd.txt Output CD Data (Apple, Orange, Kiwi)
I am assuming If I call $cd[0] using write-host, Output should be Apple, but when I call $cd[0] gets only A. What am I missing ? thank you for suggestions.