Getting first line of string in a variable using Powershell
<p>This line of code:</p>

<pre><code>$eventResult = Get-EventLog -Source ".net runtime" -LogName Application -Newest 1 | select -expandproperty message
</code></pre>

<p>Outputs a very long string into $eventResult.</p>

<p>What I'd like to do is grab the very first line of it.</p>

<p>This outputs the ENTIRE content of $eventResult:</p>

<pre><code>$eventResult | select-object -first 1
</code></pre>

<p>However, Outputting the data into a file and then parsing it works like a charm:</p>

<pre><code>$eventResult | out-file c:\output.txt
cat c:\output.txt | select-object -first 1
</code></pre>

<p>What am I missing here?</p>

<p>UPDATE:
if the output is as follows:</p>

<pre><code> Line1...
 Line2...
 Line3...
</code></pre>

<p>Then all I want is "Line1..."</p>

<p>UPDATE2:</p>

<p>I edited the $eventResult (forgot the | select message).</p>