PowerShell / vscode-powershell

Provides PowerShell language and debugging support for Visual Studio Code
https://marketplace.visualstudio.com/items/ms-vscode.PowerShell
MIT License
1.7k stars 489 forks source link

Start-EditorServices.ps1 causes a 2nd terminal to open. New terminal has execution policy set to RemoteSigned #1090

Closed BristleBeard closed 6 years ago

BristleBeard commented 6 years ago

System Details

Issue Description

When I open VS Code my terminal opens automatically with 'powershell'. If I open an existing script or start a new PS file, a 2nd terminal opens up running 'PowerShell Integrated Console'. Now I have two terminals, and the new one has a RemoteSigned execution restriction. My profile.ps1 executes again, causing the line Set-ExecutionPolicy Bypass -Scope CurrentUser to throw an error. The 'PowerShell Integrated Console' terminal also does not retain previous command history or color coding.

My non-default powershell extensions settings are these:

"powershell.enableProfileLoading": true
"powershell.codeFormatting.preset": "OTBS"

I've been unable to find where the execution policy is getting changed to RemoteSigned but I'm wondering if these two default settings are the cause of the additional terminal:

"powershell.startAutomatically": true
"powershell.integratedConsole.showOnStartup": true

Attached Screenshots

image

image

image

rkeithhill commented 6 years ago

This is a dupe of #1084. The latest release had an issue where the script file was tweaked after signing, rendering the signature hash invalid. There should be an update coming soon to resolve this issue.

BTW the PowerShell Integrated Console is similar to the ISE console where the debug session runs in that console. It can manipulated during debug and the debug state remains after the debug session finishes - just like in ISE.

BristleBeard commented 6 years ago

Please re-open this issue. It still exists in 1.51 and #1084 has been since closed.

daviwil commented 6 years ago

@BristleBeard The second terminal is the "PowerShell Integrated Terminal" which is connected to the PowerShell extension's editing and debugging experience, you definitely want it to be open. The reason why you see 2 terminals open is because VS Code falsely remembers a terminal being open the last time it was closed and pre-emptively opens a terminal for powershell.exe when it starts back up, before the PowerShell extension has a chance to start.

Is the RemoteSigned execution policy an issue for you? Can you solve this issue by calling Set-ExecutionPolicy in the $profile of the PowerShell Integrated Terminal (it's different than the default PowerShell profile)?