Skip to content

PowerShellEditorServices not working on Windows 2012 R2 Servers. #2571

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

Closed
matthew8gibson opened this issue Mar 19, 2020 · 9 comments
Closed
Labels
Resolution-Answered Will close automatically.

Comments

@matthew8gibson
Copy link

matthew8gibson commented Mar 19, 2020

I just downgraded to the previous PowerShell Extension and the issue appears to be resolved:
v2020.1.0 - Wednesday, January 15, 2020

Issue Description

PowerShell editor services are not starting on 3 different Windows 2012 R2 servers (they are in 3 different environments.). These have all been working successfully in the past.

Version: 1.43.0 (system setup)
Commit: 78a4c91400152c0f27ba4d363eb56d2835f9903a
Date: 2020-03-09T19:47:57.235Z
Electron: 7.1.11
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 6.3.9600

note:
this is happening on 3 different Windows 2012 R2 servers in 3 different environments that I use.

Steps to Reproduce:

  1. Let PowerShell Extension start, when creating or opening a PowerShell file.
  2. PS prompt doesn't start.

I think this is the core issue:

PS C:\Users\userid\.vscode\extensions\ms-vscode.powershell-2020.3.0\modules\PowerShellEditorServices>  Import-Module
 .\PowerShellEditorServices.psd1
Import-Module : The module manifest 'C:\Users\userid\.vscode\extensions\ms-vscode.powershell-2020.3.0\modules\Power
ShellEditorServices\PowerShellEditorServices.psd1' could not be processed because it is not a valid Windows PowerShell
restricted language file. Remove the elements that are not permitted by the restricted language:
At C:\Users\userid\.vscode\extensions\ms-vscode.powershell-2020.3.0\modules\PowerShellEditorServices\PowerShellEdit
orServices.psd1:12 char:18
+ RootModule = if ($PSEdition -eq 'Core')
+                  ~~~~~~~~~~
A variable that cannot be referenced in restricted language mode or a Data section is being referenced. Variables that
can be referenced include the following: $PSCulture, $PSUICulture, $true, $false, and  $null.
At line:1 char:2
+  Import-Module .\PowerShellEditorServices.psd1
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (C:\Users\wGibso...orServices.psd1:String) [Import-Module], Missing
   MemberException
    + FullyQualifiedErrorId : Modules_InvalidManifest,Microsoft.PowerShell.Commands.ImportModuleCommand

Here is error from log:
3/19/2020 2:10:27 PM [NORMAL] - Visual Studio Code v1.43.0 64-bit
3/19/2020 2:10:27 PM [NORMAL] - PowerShell Extension v2020.3.0
3/19/2020 2:10:27 PM [NORMAL] - Operating System: Windows 64-bit
3/19/2020 2:10:27 PM [NORMAL] - Language server starting --
3/19/2020 2:10:27 PM [NORMAL] - PowerShell executable: C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe
3/19/2020 2:10:27 PM [NORMAL] - PowerShell args: -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command Import-Module 'c:\Users\Administrator.vscode\extensions\ms-vscode.powershell-2020.3.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2020.3.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\Administrator.vscode\extensions\ms-vscode.powershell-2020.3.0\modules' -EnableConsoleRepl -LogLevel 'Normal' -LogPath 'c:\Users\Administrator.vscode\extensions\ms-vscode.powershell-2020.3.0\logs\1584645027-a0abfe13-cba6-46a9-a1ef-f6bafc0e81221584645008564\EditorServices.log' -SessionDetailsPath 'c:\Users\Administrator.vscode\extensions\ms-vscode.powershell-2020.3.0\sessions\PSES-VSCode-3692-740215' -FeatureFlags @()
3/19/2020 2:10:27 PM [NORMAL] - PowerShell Editor Services args: Import-Module 'c:\Users\Administrator.vscode\extensions\ms-vscode.powershell-2020.3.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2020.3.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\Administrator.vscode\extensions\ms-vscode.powershell-2020.3.0\modules' -EnableConsoleRepl -LogLevel 'Normal' -LogPath 'c:\Users\Administrator.vscode\extensions\ms-vscode.powershell-2020.3.0\logs\1584645027-a0abfe13-cba6-46a9-a1ef-f6bafc0e81221584645008564\EditorServices.log' -SessionDetailsPath 'c:\Users\Administrator.vscode\extensions\ms-vscode.powershell-2020.3.0\sessions\PSES-VSCode-3692-740215' -FeatureFlags @()
3/19/2020 2:10:27 PM [NORMAL] - powershell.exe started.
3/19/2020 2:10:27 PM [NORMAL] - Waiting for session file
3/19/2020 2:12:27 PM [NORMAL] - Error occurred retrieving session file
3/19/2020 2:12:27 PM [NORMAL] - Language server startup failed.
3/19/2020 2:12:27 PM [ERROR] - The language service could not be started:
3/19/2020 2:12:27 PM [ERROR] - Timed out waiting for session file to appear.

Does this issue occur when all extensions are disabled?: No

@ghost ghost added the Needs: Triage Maintainer attention needed! label Mar 19, 2020
@rjmholt
Copy link
Contributor

rjmholt commented Mar 19, 2020

This is because Windows Server 2012R2 runs PowerShell 4 by default, which is no longer supported by the PowerShell extension. See #1310.

Because of the way the extension loads, there's no way for us to improve the error message here unfortunately.

Some workarounds:

  • Install WMF 5.1
  • Pin the PowerShell extension to 2020.1.0
  • Install PowerShell 7

We're doing work to enable development on client OS SKUs while providing compatibility checking for deployment SKUs. See this blog post for the work here so far.

@rjmholt rjmholt added Resolution-Answered Will close automatically. and removed Needs: Triage Maintainer attention needed! labels Mar 19, 2020
@matthew8gibson
Copy link
Author

matthew8gibson commented Mar 20, 2020

thanks for the quick response!

can you tell me how to do this?
Pin the PowerShell extension to 2020.1.0
I think that's what i want as a fallback if PS itself can't be upgraded.
i got that version installed, but i'm thinking it is going to upgrade automatically at some point.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Mar 20, 2020
@NoralK
Copy link

NoralK commented Mar 20, 2020

I have a similar issue. I also have Window Server 2012-R2 but I have upgraded to WMF 5.1 as part of the VM OS image. I get the same error message as above. Is PowerShell v7 required to be installed, I did not see a prereq for this?

Using PowerShell Extension v2020.3.0 - is there a reason for a specific version of 2020.1.0?

@matthew8gibson
Copy link
Author

I was able to apply WMF 5.1 on one box and it resolved the issue.

On another box, I was able to stay at version 2020.1.0 and it resolved the issue. I also configured all extensions to NOT autoupdate..

note: I don't see a way to let others update automatically and keep this one at the old version. I wonder if there is one

PowerShell Extension v2020.3.0 no longer supports old versions of PowerShell.

@TylerLeonhardt
Copy link
Member

TylerLeonhardt commented Mar 20, 2020

@NoralK

Is PowerShell v7 required to be installed, I did not see a prereq for this?

This is not a requirement. You can also use Windows PowerShell 5.1. If you're still seeing an issue on startup, please open a new issue and also attach the logs so we can get a better idea of what's going on.

@matthew8gibson I'm in the process of adding a docs change to make this easier to discover:

MicrosoftDocs/PowerShell-Docs#5617

You'll want the "extensions.autoUpdate": false setting.

@TylerLeonhardt TylerLeonhardt removed the Needs: Maintainer Attention Maintainer attention needed! label Mar 20, 2020
@matthew8gibson
Copy link
Author

Thanks, Tyler. If others can understand the underlying problem more quickly than I did that'd be great.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Mar 20, 2020
@TylerLeonhardt TylerLeonhardt removed the Needs: Maintainer Attention Maintainer attention needed! label Mar 20, 2020
@BrendonOSullivan
Copy link

upgrading to WMF 5.1 fixed this issue for me.
Currently it is a real blocker for anyone affected and I only found this solution after hours of googling, re-installing, restarting and the usual nightmare.
Two years after the first post this issue should be fixed by now or at least an understandable error message!

@ghost
Copy link

ghost commented Mar 16, 2022

Thank you for your comment, but please note that this issue has been closed for over a week. For better visibility, consider opening a new issue with a link to this instead.

@andyleejordan
Copy link
Member

Thanks @BrendonOSullivan, I'll get this added to the troubleshooting guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution-Answered Will close automatically.
Projects
None yet
Development

No branches or pull requests

6 participants