How to call a second window in powershell and write to it
<p>What I am trying to do is run a .ps1 script and while it is executing, it opens a new powershell window and writes certain text to it.</p>

<p>Opening a new window is simple. Among the many ways to do it, I chose <code>start Powershell</code>. However, the problem that I am having is that when I type <code>write-host "ipsum lorem"</code> it writes it into the native window. </p>

<p>I figured I may have to call the second powershell window and hold that in a variable or object and then write to said variable or object. Every time I try to search in Google, the only results are how to write output and it doesn't talk about running scripts in the native window and writing to a different window altogether. </p>

<p>I understand that <code>write-host</code> writes to the native window but I couldn't find anything through <code>man write-*</code>/<code>get-help write-*</code> or through Google searches. </p>

<p>Can anyone point me in the right direction with this and let me know where I might begin to look?</p>

<hr>

<p>Here is an example:</p>

<pre><code>start powershell

if($var -eq $sum) {
    # I want this to be written to the second window
    write-host "This condition was met."
} else {
    # I want this to be written to the second window
    write-host "This condition was not met."
}
</code></pre>

<p>I know that <code>write-host</code> shouldn't be used as this writes to the native window but I was just putting it there as a placeholder. Bear with me.</p>

<p>Thanks in advance. </p>