Whenever I open a PowerShell file (ps1 / psm1) the extension crashes like so:




I tried the following to no effect:
6/23/2020 5:30:07 PM [NORMAL] - Visual Studio Code v1.46.1 64-bit
6/23/2020 5:30:07 PM [NORMAL] - PowerShell Extension v2020.6.0
6/23/2020 5:30:07 PM [NORMAL] - Operating System: Windows 64-bit
6/23/2020 5:30:07 PM [NORMAL] - Language server starting --
6/23/2020 5:30:07 PM [NORMAL] - PowerShell executable: C:\Users\ohad1\.dotnet\tools\pwsh.exe
6/23/2020 5:30:07 PM [NORMAL] - PowerShell args: -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command Import-Module 'c:\Users\ohad1\.vscode\extensions\ms-vscode.powershell-2020.6.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2020.6.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\ohad1\.vscode\extensions\ms-vscode.powershell-2020.6.0\modules' -EnableConsoleRepl -StartupBanner "=====> PowerShell Integrated Console v2020.6.0 <=====
" -LogLevel 'Normal' -LogPath 'c:\Users\ohad1\.vscode\extensions\ms-vscode.powershell-2020.6.0\logs\1592922607-427b8a15-52cc-47ce-b42c-273cfda30f671592922585773\EditorServices.log' -SessionDetailsPath 'c:\Users\ohad1\.vscode\extensions\ms-vscode.powershell-2020.6.0\sessions\PSES-VSCode-22388-563996' -FeatureFlags @()
6/23/2020 5:30:07 PM [NORMAL] - PowerShell Editor Services args: Import-Module 'c:\Users\ohad1\.vscode\extensions\ms-vscode.powershell-2020.6.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2020.6.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\ohad1\.vscode\extensions\ms-vscode.powershell-2020.6.0\modules' -EnableConsoleRepl -StartupBanner "=====> PowerShell Integrated Console v2020.6.0 <=====
" -LogLevel 'Normal' -LogPath 'c:\Users\ohad1\.vscode\extensions\ms-vscode.powershell-2020.6.0\logs\1592922607-427b8a15-52cc-47ce-b42c-273cfda30f671592922585773\EditorServices.log' -SessionDetailsPath 'c:\Users\ohad1\.vscode\extensions\ms-vscode.powershell-2020.6.0\sessions\PSES-VSCode-22388-563996' -FeatureFlags @()
6/23/2020 5:30:07 PM [NORMAL] - pwsh.exe started.
6/23/2020 5:30:07 PM [NORMAL] - Waiting for session file
6/23/2020 5:34:08 PM [NORMAL] - Timed out waiting for session file to appear.
6/23/2020 5:34:08 PM [NORMAL] - Language server startup failed.
6/23/2020 5:34:08 PM [ERROR] - The language service could not be started:
6/23/2020 5:34:08 PM [ERROR] - Error: Timed out waiting for session file to appear.
It looks like the < in the StartupBanner is causing the issue
| Name | Version |
| --- | --- |
| Operating System | Windows_NT x64 10.0.18363 |
| VSCode | 1.46.1|
| PowerShell Extension Version | 2020.6.0 |
PS C:\> $psEditor.EditorServicesVersion
PS C:\> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.18362.752
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.752
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
I don't know why 5.1 is loaded - I have the latest PowerShell Core (7.0.02) installed and working (e.g. in Windows Terminal).
Visual Studio Code Extensions(Click to Expand)
|Extension|Author|Version|
|---|---|---|
|azure-account|ms-vscode|0.8.11|
|azurerm-vscode-tools|msazurermtools|0.11.0|
|ginfuru-vscode-jekyll-syntax|ginfuru|0.1.1|
|html-preview-vscode|tht13|0.2.5|
|language-liquid|neilding|0.1.1|
|mssql|ms-mssql|1.9.0|
|powershell|ms-vscode|2020.6.0|
|remote-wsl|ms-vscode-remote|0.44.4|
|team|ms-vsts|1.161.0|
|vscode-aks-tools|ms-kubernetes-tools|0.0.6|
|vscode-docker|ms-azuretools|1.3.1|
|vscode-dotnet-runtime|ms-dotnettools|0.1.2|
|vscode-kubernetes-tools|ms-kubernetes-tools|1.2.1|
|vscode-yaml|redhat|0.8.0|
|xml|DotJoshJohnson|2.5.0|
PowerShell executable: C:\Users\ohad1.dotnet\tools\pwsh.exe
From your logs it looks like you're using the .NET Global Tool. What version of the .NET Global Tool do you have installed?
PS> C:\Users\ohad1\.dotnet\tools\pwsh.exe
PS> $PSVersionTable
Correct, here's the output from C:\Users\ohad1\.dotnet\tools\pwsh.exe:
$PSVersionTable
Name Value
---- -----
PSVersion 7.0.2
PSEdition Core
GitCommitId 7.0.2
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Thanks @ohadschn does this reproduce if you use another version of PowerShell rather than the dot net global tool, to set your default PowerShell version use:
"powershell.powerShellDefaultVersion": "PowerShell Preview (x64)",
Thanks @ohadschn does this reproduce if you use another version of PowerShell rather than the dot net global tool, to set your default PowerShell version use:
"powershell.powerShellDefaultVersion": "PowerShell Preview (x64)",
Thank you, unfortunately it still reproduces with that setting (restarted vscode)
Thanks @ohadschn sorry to hear that this issue is still reproducing, what installation method did you use for PowerShell preview?
I'm not sure I follow, I don't have PowerShell preview installed as far as I know.
Did you mean for it to install it and then try "powershell.powerShellDefaultVersion": "PowerShell Preview (x64)"?
@ohadschn sorry that was totally my bad, I forgot to update the snippet I sent you, that would work (ie. installing PowerShell preview first) or if you are running on Windows you could instead try:
"powershell.powerShellDefaultVersion": "Windows PowerShell (x64)"
No worries, I definitely share the blame for blindly copy-pasting. I am indeed running on Windows, and the new setting ("powershell.powerShellDefaultVersion": "Windows PowerShell (x64)") seems to do the trick! (that is all errors are gone)
However that gives me PS 5.1 while I need PS Core (7), and reverting the above config change unfortunately reproduces the problem... Does that mean I need to uninstall the .NET global tool and install the "regular" MSI package?
Does that mean I need to uninstall the .NET global tool and install the "regular" MSI package?
This seems likely at this point... can you give it a try?
I'd like to get to the bottom of why the Global Tool isn't working for you... is your computer's language set to something that isn't english? Do you use a different keyboard layout? (just shots in the dark... I should probably go try the global tool myself...)
FWIW, the MSI is faster than the Global Tool so frankly I recommend the MSI anyway.
Thanks, I can confirm .NET tool uninstall + install regular PS MSI works! Sure is good enough for me, but I do like the global tool approach because it's basically a package manager - not crazy about going off to download MSIs every time a new version comes out... When WinGet is GA I guess that won't be an issue though (assuming this behavior doesn't reproduce there of course).
As for my setup, pretty straightforward - display language is English, preferred language it English (I do have Hebrew installed alongside it but it never caused any issue AFAIK). English keyboard layout is standard US QWERTY...
Cc @adityapatwardhan about global tool.
@ohadschn There's also a setting to suppress the startup banner... I wonder if that would fix the issue. I have doubt, but it might. Not sure what it is off the top of my head.
@TylerLeonhardt the setting is: powershell.integratedConsole.suppressStartupBanner setting this to true does skip the error:

But the extension then proceeds with another series of unclear errors (the script executes fine outside VS Code):
Clear-Host: E:\Projects\xyz\acme\build\update-script.ps1:30:1
Line |
30 | Clear-Host;
| ~~~~~~~~~~
| The term 'Clear-Host' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path
| was included, verify that the path is correct and try again.
_(I seemingly cannot add a newline after a code block in my previous comment)_
@TylerLeonhardt as an update, when I downgrade to v2020.1.0 of the extension my script runs fine in VS Code, any update after that breaks and gives me that Clear-Host error regardless of supressing the banner.
Edit: I have PS 7.0.2 installed through the MSI on Github, as well as the Global Tool 7.0.2.
any update after that breaks and gives me that Clear-Host error regardless of suppressing the banner.
This is strange. It sounds like needed modules might not be imported. Perhaps your profile sets the PSModulePath?
The banner issue looks like the argument to set the banner hasn't been quoted/escaped properly. If this is dotnet global tool specific, then it may be due to dotnet having some expectation about how parameters are passed. There are several layers to pass parameters through there and this gets pretty dicey.
I'm able to reproduce this issue. I'll see if I can take a look at some point. Currently working on several things already, but hopefully I can find some time this week
This is strange. It sounds like needed modules might not be imported. Perhaps your profile sets the PSModulePath?
If I start the extension with load profile disabled (powershell.enableProfileLoading: false) it still occurs. I can figure out though where the files are located and see what is happening there.
@TylerLeonhardt the setting is:
powershell.integratedConsole.suppressStartupBannersetting this to true does skip the error:
@JosKrause
Thank you very much! After searching ~2 hours, that setting removed the issue that the language server can not start!
By the way: I used this version of powershell core as a dotnet global tool:
Name Value
---- -----
PSVersion 7.1.0
PSEdition Core
GitCommitId 7.1.0
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
And the v2020.6.0 of the PowerShell extension.
@rjmholt could you re-open this? I'm seeing what appears to be the same issue using the latest extension (v2020.6.0) and PS Core 7.1.1 installed as a global tool (setting suppressStartupBanner to true resolves the issue).
@ohadschn Try PowerShell 7.1.3, we don't think the fix was in 7.1.1.
@andschwa looks good, thanks!
Most helpful comment
Thanks, I can confirm .NET tool uninstall + install regular PS MSI works! Sure is good enough for me, but I do like the global tool approach because it's basically a package manager - not crazy about going off to download MSIs every time a new version comes out... When WinGet is GA I guess that won't be an issue though (assuming this behavior doesn't reproduce there of course).
As for my setup, pretty straightforward - display language is English, preferred language it English (I do have Hebrew installed alongside it but it never caused any issue AFAIK). English keyboard layout is standard US QWERTY...