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:
param ( $Show )
if ( !$Show )
PowerShell -NoExit -File $MyInvocation.MyCommand.Path 1
# Put your code here...
Write-Output 'I will not go away!'