Keep your PowerShell script open when executed

Whenever you execute a PowerShell script it will run and do its thing, but afterwards it will close PowerShell.
Only when you already have a prompt or scripting editor open and execute the script from there, PowerShell will remain open.

There is a solution for this, specifically the -NoExit parameter to PowerShell.exe
You may want to execute a script, by rightclicking the script and select ‘Run with PowerShell’, and leave the shell open when its finished… that may be a little tricky to do 😉
When you start your script with the following, it will accomplish that task:


  1. Bob says:

    Thanks for that!

  2. Caleb says:

    This was helpful, however, using this, the script cannot be run in the powershell editor, which is a bummer. Is there any fix for this?

  3. Jeff Wouters says:

    Hi Caleb,
    Correct. But I see executing scripts and executing scripts from an editor as two very different scenario’s. Keeping a script/console open is mainly used for viewing output. You aready see output when you execute this from an editor. So you wouldn’t need it, right?

  4. Stephen Culbertson says:

    This works perfect. Thank you for taking the time to post this.

  5. SJO says:

    awesome thx!

Leave a Reply

Your email address will not be published. Required fields are marked *