The get-content cmdlet does remove line-feeds, but it actually reads each
line into a string object, and stores each line in an array. From the help:
Quote:
>get-help get-content
<snip>
DETAILED DESCRIPTION
It reads the content one line at a time and returns an object for each
line.
#Example:
Quote:
>get-content -path test1.txt|write-host
Line1
Line2
Quote:
>$a = get-content -path test1.txt
>$a.Length
2 # 2 objects in the array, not a string of 2 characters
Line1
Line2
Quote:
>set-content -path test2.txt $a
>get-content -path test2.txt|write-host
Line1
Line2
Quote:
>get-content -path test2.txt|write-host -noNewLine
Line1Line2
Most Windows text files end lines with 2 characters, the carriage-return +
line-feed (\r\n or Chr13 + Chr10). Maybe there's something different about
your original text, maybe it comes from Unix/Linux or Mac, and it only
contains a line-feed or carriage-return but not both?
"ssg31415926" <newsjunkmail@xxxxxx> wrote in message
news:8c837cc7-dfb8-425f-8eaa-102c731922d2@xxxxxx
Quote:
> I've tried reading a text file using
>
> $reportContent = get-content -path $tempFilePath
>
> but it loses the line-feeds so I just get one long string. Can I do
> it with get-content or do I need to use a StreamReader or something
> similar?