[this article contains the text originally posted in NppExec's forum]
The problem: if you execute a PowerShell's script in NppExec's Console, the PowerShell process is not ended when the script is finished.
The solution: use "cmd /c echo. | powershell" instead of "powershell" to emulate sending of the Enter key to PowerShell process.
Here is an example of the full NppExec's script:
// path to PowerShell.exe set local PS_EXE = C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe // temporary file set local TEMP_FILE = $(SYS.TEMP)\ps_sel.ps1 // save selected text from current file to a temporary ANSI file SEL_SAVETO $(TEMP_FILE) :a // execute the temporary file in PowerShell and exit cmd /c echo. | "$(PS_EXE)" -nologo "$(TEMP_FILE)"