-
Notifications
You must be signed in to change notification settings - Fork 513
Cannot run PowerShellEditorServices when execution policy is set to AllSigned #1048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I reinstalled Visual Studio Code, and re-installed the PowerShell plugin and now the terminal loads but it takes a long time to load. I did not time it but it seemed to take about 90+ seconds. |
Hey Chad, has the situation improved for you with VS Code 1.17.2? I believe there was a performance issue with the Integrated Terminal that might have been causing this. |
Hello, I am having the same issue.
I tried running I got: Interestingly enough, it works fine when running VSCode as an Administrator. I can confirm the bug exists on both Stable 1.18.0 and Insiders 1.19.0 |
I am seeing the same thing. 12/8/2017 8:40:31 AM [NORMAL] - Visual Studio Code v1.18.1 64-bit In the log it also shows that it downloads omnisharp every time I try to run a powershell script. At the end it will show a message at the top of the editor "Cannot read property 'length' of undefined" I overrode the following settings:
|
@jcoryatjr You do not want the following setting set to
This setting, when set to |
Regression in 2018-01-30 Insiders:
|
@tmknight (or anyone with this issue) can you enable verbose logging and attach the logs here? Here are instructions: |
@tmknight looks like the integrated terminal in VSCode (insiders) isn't working at all in today's daily build. With the PowerShell extension disabled, if you open the integrated terminal like so: The terminal flashes open and disappears. This would explain why we are seeing the error you are getting. My recommendation:
The issue opened on them for this is here: microsoft/vscode#42516 |
To @jcoryatjr, @legendaryleo7, and @phunkodelic. Are you folks still experiencing this issue on stable (or any insider build before today)? |
@tylerl0706 Let me know if you need additional info - though I see Insiders has been updated and the issue is resolved. Cheers |
@tylerl0706 Here's the logs from Stable - 2018-01-25: And Insiders - 2018-01-30 I've noticed that there seems to be no issue when running with elevated permissions. I use a standard account and elevate when updating/installing stuff with an admin account. I wonder if that's related to it (in my case at least). I'm using other terminal emulators like ConEmu and Cmder with no problem. |
I have also the same issue. Here is the log.
I've enable the loging to verbose, but nothing more is added to the logfile. And the file EditorServices.log is not created...I'm running vscode without administrator rights. Any ideas? Thank you. |
I can confirm, I am having the same problem with VSCode 1.19.2 and PowerShell extension 1.5.1. No integrated terminal will open, powershell or otherwise unless I run the program with elevated credentials. Logs are the same as what everyone else is seeing, but have been pasted in below. 2/13/2018 8:13:36 PM [NORMAL] - Visual Studio Code v1.19.2 64-bit |
Is there an EditorServices.log file at this location: |
OK, well that is consistent with the PSES module not getting far enough along to even create the log file. |
It looks like you redacted your username for the log output but this piece remains:
Is there any error message output? |
You are correct, it was a missed/error redaction...anywho, when I run the command you gave me in a PS window, it goes to PowerShell Integrated Console, and then nothing else happens. |
So in this case, there is an EditorServices.log file in the |
Yes, pasted below 2/13/2018 8:31:46 PM [NORMAL] - Method "StartLogging" at line 144 of C:\projects\powershelleditorservices\src\PowerShellEditorServices.Host\EditorServicesHost.cs
2/13/2018 8:31:46 PM [NORMAL] - Method "StartLanguageService" at line 180 of C:\projects\powershelleditorservices\src\PowerShellEditorServices.Host\EditorServicesHost.cs
2/13/2018 8:31:47 PM [NORMAL] - Method "StartDebugService" at line 254 of C:\projects\powershelleditorservices\src\PowerShellEditorServices.Host\EditorServicesHost.cs
|
OK, so the PSES module starts up correctly but something seems to go wrong in trying to attach it to the VSCode terminal window. Do you have any special integrated terminal settings set in your user (or workspace) settings? |
I don't, it's a fresh installation |
Hmm... |
Is there any difference if you execute this (was missing some PowerShell.exe params):
|
Unfortunately, no, the console goes to the same integrated console message with the same output in the EditorServices log...this really makes no sense. Makes me believe it's some type of security control that is in place on my work laptop. |
AFAICT that is exactly the exe & args passed to the VSCode API that creates the terminal (starts PSES) e.g. this.consoleTerminal =
vscode.window.createTerminal(
this.title,
powerShellExePath,
powerShellArgs); Can you try an experiment? Start task manager, go to the Details pane and sort by Name and then find the PowerShell processes and select one (to keep window from scrolling). Now start a debug session in VSCode and see if a new PowerShell appears in the list. It might not run for long. You might want to set the task manager View -> Update speed to High to increase the chances of seeing PowerShell.exe spin up. If this doesn't work, there is a WMI event that will fire whenever a new process starts but I don't remember the syntax for that command off the top of my head. |
So, I did do this, and I briefly saw another powershell process spawn, then die. This happened about 4 times before VSCode timed out trying to load the engine. |
I'm not seeing anything in either log pertaining to the problem. I appreciate all the help, but at this point I think I'm simply better off using the PS ISE |
Hi @davidm1984, we just did some work on this to make sure the certificates are all correct and up to date with the modules and scripts -- everything is Authenticode signed. Would you be able to give some more info on the problem you experienced here and what you needed to do to work around it? You mentioned a build script, but do you mean the scripts to build from source? Or something in the released VSIX? |
Hi all, |
Hi @rjmholt, I just tested this, and it seems to be working just fine now with the GPO set to AllSigned. No issues loading VS Code or the Powershell Extension at all. Intellisense and everything seems to be working as intended. (VS Code 1.28.0 and Powershell extension 1.9.0.) Thank you for making that happen! |
Closing for now -- if the issue recurs, we can reopen |
I know this was closed... but the issue seems to have popped up again with version 1.10.2 of the extension. With AllSigned GPO applied the language service fails to start. With Unrestricted it opens and runs just fine. Wondering if PS Editor Services was signed with the wrong cert again before publishing that version? |
@Ryoken0367 I want to make sure it's actually a result of the 1.10.2 release. Can you install 1.10.1 or 1.10? |
I spoke with @TravisEz13 about this and confirmed that we are indeed signing correctly with the correct certificate. The problem is that PowerShell trusts no signing certificate out of the box and you need to add the certificate to your trusted cert list yourself. This isn't something we should ever do automatically, but we should ideally ship a script that will do it all when invoked. Here's an implementation: # Temp file path to put the cert on
$certPath = Join-Path $env:TEMP powershelleditorservices.cer
# The signature for the EditorServices module file
$sig = Get-AuthenticodeSignature C:\Users\roholt\.vscode\extensions\ms-vscode.powershell*\modules\PowerShellEditorServices\PowerShellEditorServices.psd1
# Export the signing certificate to a file for import
$sig.SignerCertificate.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Cert) > $certPath
# Import the certificate into the machine's cert store
Import-Certificate -FilePath $certPath -CertStoreLocation Cert:\CurrentUser\TrustedPublisher |
Reopening to track shipping a script to do this |
@Ryoken0367 can you confirm that @rjmholt's script works? Keep in mind, you need to make a small tweak to the path in the example. |
Nope, it doesn't work and I'm not sure why he thought it would.
|
Sorry, typo: |
Also note that this will only work in Windows PowerShell for now, since it depends on the PKI module |
I've looked into this a bit more (above script was a naive attempt to turn a GUI procedure into script). Here's a script that I've verified works on my machine: # The signature for the EditorServices module file
$cert = (Get-AuthenticodeSignature ~\.vscode\extensions\ms-vscode.powershell*\modules\PowerShellEditorServices\PowerShellEditorServices.psd1).SignerCertificate
# Get the Cert:\CurrentUser\TrustedPublisher cert store
# IMPORTANT: You may not want CurrentUser here -- change to your needed location
$store = [System.Security.Cryptography.X509Certificates.X509Store]::new("TrustedPublisher", "CurrentUser")
# Open the store
$store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::MaxAllowed)
# Add the cert to the TrustedPublishers store
$store.Add($cert) |
That worked, I left it at CurrentUser, since I'm the only user of this computer. No errors, and the integrated console loads without issue now as well. |
After workshopping a good way to trust the MS certificate (the obvious problem being that any PowerShell script to trust the certificate would also be untrusted), it turns out a very simple way is to just interactively import the editor services module and select So: ipmo ~/.vscode/ms-vscode.powershell*/modules/PowerShellEditorServices/PowerShellEditorServices.psd1 |
@SydneyhSmith we can doc this workaround in https://docs.microsoft.com/en-us/powershell/scripting/components/vscode/using-vscode?view=powershell-6 or somewhere in docs.microsoft.com It could go in our troubleshooting doc in GitHub, but I feel like this would be better in a slightly more official location |
@TylerLeonhardt Yeah I'm thinking it should live in docs, we can decide if it should be a sub category or a doc of its own--adding it to my backlog 😄 |
Closing as this has now been documented MicrosoftDocs/PowerShell-Docs#3612 |
System Details
$PSVersionTable
:PS C:\Users\q794776> $PSVersionTable
Name Value
PSVersion 5.0.10586.117
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.10586.117
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Issue Description
Terminal does not work. It worked before I performed the VScode upgrade which was done today.
Attached Logs
10/9/2017 3:28:03 PM [NORMAL] - Visual Studio Code v1.17.0 64-bit
10/9/2017 3:28:03 PM [NORMAL] - PowerShell Extension v1.4.3
10/9/2017 3:28:03 PM [NORMAL] - Operating System: Windows 64-bit
10/9/2017 3:28:03 PM [NORMAL] - Language server starting --
10/9/2017 3:28:03 PM [NORMAL] - exe: C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe
10/9/2017 3:28:03 PM [NORMAL] - args: C:\Users\q794776.vscode\extensions\ms-vscode.powershell-1.4.3\scripts\Start-EditorServices.ps1 -EditorServicesVersion '1.4.1' -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '1.4.3' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'C:\Users\q794776.vscode\extensions\ms-vscode.powershell-1.4.3\modules' -EnableConsoleRepl -LogLevel 'Normal' -LogPath 'C:\Users\q794776.vscode\extensions\ms-vscode.powershell-1.4.3\logs\1507577283-8fc44e83-a80e-4a7f-bcf2-67761b34ccaf1507577267715\EditorServices.log' -SessionDetailsPath 'C:\Users\q794776.vscode\extensions\ms-vscode.powershell-1.4.3\sessions\PSES-VSCode-4180-886972' -FeatureFlags @()
10/9/2017 3:28:03 PM [NORMAL] - powershell.exe started, pid: 9620
10/9/2017 3:29:03 PM [NORMAL] - Language server startup failed.
10/9/2017 3:29:03 PM [ERROR] - The language service could not be started:
10/9/2017 3:29:03 PM [ERROR] - Timed out waiting for session file to appear.
The text was updated successfully, but these errors were encountered: