Double check the type of $a, I'll bet it is:
41> $a.GetType().Name
Object[]
Which is probably really an array of string:
42> $a | %{$_.gettype().name}
String
String
String
String
String
My guess is that you observed the output of $a in one concatenated string by
executing something like:
"$a"
If that is the case then PowerShell will use the value of $OFS (output field
separator) to separate the elements of the array as it flattens them into
the string. You could use $OFS="," for instance to get the whole array spit
out as a single string where each element is comma separated. However if
you want to maintain the line terminators then you can set
$OFS=[Environment]::Newline.
--
Keith
"Chris" <soulxflare@xxxxxx> wrote in message
news:0d6b36bc-4814-437d-9ab5-18af590f9cef@xxxxxx
> Good stuff, that'll do. Thanks again.
>
>
> On Feb 3, 12:22 pm, Rob Campbell
> <RobCampb...@xxxxxx> wrote:
>> $a = get-content $file
>> $a |% {write-host $_}
>>
>> "Chris" wrote:
>> > I have a text file formatted like so: >>
>> > ....
>> > Property1: Value1
>> > Property2: Value2
>> > Property3: Value3
>> > .... >>
>> > If I run the line "$a = get-content $file", is there anyway I can use
>> > the write-host cmdlet and retain the line breaks? Currently I get the
>> > following: >>
>> > Property1: Value1 Property2: Value2 Property3: Value3 ... >> >