Closed
PowerShell/PowerShellEditorServices
#2066
@skycommand

Description

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
    • Not necessary in this case.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.
    • Not a security issue.

Summary

Hello. After installing the PowerShell extension, several new settings get added to Visual Studio Code, one of them is called "PowerShell › Developer: Editor Services Log Level" (powershell.developer.editorServicesLogLevel). The UI offers me several choices for this setting:

  • Diagnostics
  • Verbose
  • Normal
  • Warning
  • Error
  • None

However, it appears the "None" setting is invalid.

Today, I set powershell.developer.editorServicesLogLevel to None (via the UI). The extension prompted for a restart. Open the restart, the extension failed to start, generating the following error message:

The terminal process "C:\Program Files\PowerShell\7\pwsh.exe [...]" terminated with exit code: 1.

Full error message (click me)

The terminal process "C:\Program Files\PowerShell\7\pwsh.exe '-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command', 'Import-Module 'c:\Users\BRAINZ.vscode\extensions\ms-vscode.powershell-2023.6.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2023.6.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\BRAINZ.vscode\extensions\ms-vscode.powershell-2023.6.0\modules' -EnableConsoleRepl -StartupBanner "PowerShell Extension v2023.6.0
Copyright (c) Microsoft Corporation.

https://aka.ms/vscode-powershell
Type 'help' to get help.
" -LogLevel 'None' -LogPath 'c:\Users\BRAINZ\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\logs\1694633969-3d04be6b-b942-463a-8b12-1455353dd7661694633907551\EditorServices.log' -SessionDetailsPath 'c:\Users\BRAINZ\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\sessions\PSES-VSCode-8676-414595.json' -FeatureFlags @() '" terminated with exit code: 1.

I tried simulating the launch process explained in the message by issuing the following commands:

& 'C:\Program Files\PowerShell\7\pwsh.exe' -NoProfile -ExecutionPolicy 'Bypass'

Import-Module 'e:\Programs\Visual Studio Code\data\extensions\ms-vscode.powershell-2023.6.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'

Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2023.6.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'e:\Programs\Visual Studio Code\data\extensions\ms-vscode.powershell-2023.6.0\modules' -EnableConsoleRepl -StartupBanner "PowerShell Extension v2023.6.0
Copyright (c) Microsoft Corporation.

https://aka.ms/vscode-powershell
Type 'help' to get help.
" -LogLevel 'None' -LogPath 'e:\Programs\Visual Studio Code\data\user-data\User\globalStorage\ms-vscode.powershell\logs\1694635914-512c5bcf-1a69-4a92-94a7-14df9ca2e3c21694635892002\EditorServices.log' -SessionDetailsPath 'e:\Programs\Visual Studio Code\data\user-data\User\globalStorage\ms-vscode.powershell\sessions\PSES-VSCode-9504-479834.json' -FeatureFlags @()

And here is the output:

Start-EditorServices:
Line |
   6 |  " -LogLevel 'None' -LogPath 'e:\Programs\Visual Studio Code\data\user …
     |              ~~~~~~
     | Cannot bind parameter 'LogLevel'. Cannot convert value "None" to type "Microsoft.PowerShell.EditorServices.Hosting.PsesLogLevel". Error: "Unable to match the identifier name None to a valid enumerator name. Specify one of the following enumerator names and try again:
Diagnostic, Verbose, Normal, Warning, Error"

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.3.6
PSEdition                      Core
GitCommitId                    7.3.6
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0.}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

1.82.0
x64

Extension Version

Steps to Reproduce

  1. Install Visual Studio Code 1.82.0, which is the latest version as of this moment.
  2. Install the PowerShell extension.
  3. Open a new file (Ctrl+N).
  4. Set the language to PowerSehll.
  5. Wait for the PowerShell console to launch. (Some people call it PowerShell's terminal.)
  6. Open Settings (Ctrl+,).
  7. Find "Editor Services Log Level". Confirm that it corresponds to powershell.developer.editorServicesLogLevel.
  8. Use the drop down box to set the setting to None.
  9. Agree to restart the PowerShell language server.

Visuals

The powershell.developer.editorServicesLogLevel in its default mode.
1

Changing it:
2

The restart prompt:
3

A PowerShell error message briefly flashes across the screen, then disappears.
4

Visual Studio Code reports error.
5

Logs

This issue is about logs themselves.