<p>I have recently started working with Kubernetes and Docker and still new with how it all works. I have made a ps1 script to run all the steps I need to do to build image and execute image on Kubernetes. </p>

<p>What I see is all steps work fine on ISE (except this one: "kubectl exec -it test-runner pwsh"). For this step alone, I have to run it on another PowerShell window. </p>

<p>When I run this step in ISE, the script keeps running without ever giving any error or stopping. </p>

<p>Does anyone know if its a limitation with Kubernetes working on ISE or if there is a workaround to make it work? </p>

<p>Working with ISE is quick and saves me tons of time, so this really makes a difference when I have to copy, paste, enter this each time in a separate PowerShell window.</p>

<p>Thanks in advance for your help!</p>

<p>P.S: I looked at other suggested similar questions/answers and none of them seem to be related to Kubernetes not working on ISE. Hence this question. </p>

<p>command: </p>

<pre><code>kubectl exec -it test-runner pwsh
</code></pre>

<p>Expected (and actual when running from PowerShell console):</p>

<pre><code>----------------------
PS C:\windows\system32&gt; kubectl exec -it test-runner pwsh
PowerShell 6.2.2
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS /test&gt;
-----------------------------
Actual (when running from PowerShell ISE):

PS C:\SourceCodeTLM\Apollo&gt;  kubectl exec -it test-runner pwsh
PowerShell 6.2.2
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

(with a blinking cursor and script running without breaking and changing to the new path)...
-----------------------------------------------
</code></pre>

<p><strong>The PowerShell <em>ISE</em> doesn't support <em>interactive</em> console applications</strong>, which notably means that you cannot start other <em>shells</em> from it.</p>
<p>The ISE tries to anticipate that problem by refusing to start well-known shells.
For instance, trying to start <code>cmd.exe</code> fails with the following error message:</p>
<pre class="lang-none prettyprint-override"><code>Cannot start &quot;cmd&quot;. Interactive console applications are not supported. 
To run the application, use the Start-Process cmdlet or use 
&quot;Start PowerShell.exe&quot; from the File menu.
</code></pre>
<p>Note:</p>
<ul>
<li><code>pwsh.exe</code>, the CLI of PowerShell (Core) 7+, is <em>not</em> among the well-known shells, which indicates the <strong><a href="https://learn.microsoft.com/en-us/powershell/scripting/components/ise/introducing-the-windows-powershell-ise#support" rel="nofollow noreferrer">ISE's obsolescent status</a></strong>. It is <strong>being superseded by <a href="https://code.visualstudio.com/" rel="nofollow noreferrer">Visual Studio Code</a> with the <a href="https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell" rel="nofollow noreferrer">PowerShell extension</a></strong>. Obsolesence aside, there are other pitfalls - see the bottom section of <a href="https://stackoverflow.com/a/57134096/45375">this answer</a>.</li>
</ul>
<p>However, it is impossible for the ISE to detect all cases where a given command (ultimately) invokes an interactive console application; when it doesn't, <strong>invocation of the command is attempted, resulting in obscure error messages or, as in your case, hangs</strong>.</p>
<p>As the error message shown for <code>cmd.exe</code> implies, <strong>you must run interactive console applications <em>outside</em> the ISE, in a regular console window.</strong></p>
<p><strong>From the ISE</strong> you can <strong>use <a href="https://learn.microsoft.com/powershell/module/microsoft.powershell.management/start-process" rel="nofollow noreferrer"><code>Start-Process</code></a> to launch a program in a new, regular console window</strong>; in the case at hand:</p>
<pre><code>Start-Process kubectl 'exec -it test-runner pwsh'
</code></pre>
<p><strong>Alternatively</strong>, run your PowerShell sessions outside the ISE to begin with, such as in a regular console window, <strong>Windows Terminal</strong>, or in <strong>Visual Studio Code's integrated terminal</strong>.</p>
