You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am sure this issue is with PowerShell Editor Services itself and does not reproduce in a standalone PowerShell instance, and is not an issue with my editor.
I have verified that I am using the latest version of PowerShell Editor Services.
When the following code snippet is encountered in a user created PowerShell script, and the script's path is in the environment path variable, PowerShellEditorServices fails. This appears to be caused by a Newtonsoft.Json.JsonSerializationException (For additional details, see the included PowerShellEditorServices-14896.log file included below).
Because the PowerShellEditorServices is used by the PowerShell Extension for Visual Studio Code, both the extension's Command Explorer and Intellisense stop working when this exception occurs. Ideally, I feel the PowerShellEditorServices should gracefully handle and report the exception and continue running.
param ( [Parameter(Mandatory=$false)] [ValidateScript({ if ($_ -is [int] -and $_ -ge 0) { $true } else { throw "The input argument be a positive integer or zero." } })] [int]$DaysBack = 0 # Default value is 0 )
PowerShell Version
PS ~> $PSVersionTable Name Value---- -----PSVersion 7.4.3PSEdition CoreGitCommitId 7.4.3OS Microsoft Windows 10.0.22631Platform Win32NTPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}PSRemotingProtocolVersion 2.3SerializationVersion 1.1.0.1WSManStackVersion 3.0
Editor Version
Installed PowerShell Extension for Visual Studio Code.
PowerShell Editor Services Version
N/A
Steps to Reproduce
In Windows 11:
Insert aforementioned code snippet into any user defined PowerShell script.
Make sure the script can be found by the PowerShellEditorServices by including its fully qualified path (not file name) in the path environment variable.
Open Visual Studio Code (with the PowerShell for VS Code extension (by Microsoft) installed.
Click on the PowerShell icon in the left panel, to show the Command Explorer. (You may need to enable this extension's setting: PowerShell>SideBar: Command Explorer Visibility
The Command Explorer will fail to enumerate and Intellisense will stop working for PowerShell scripts.
Prerequisites
Summary
When the following code snippet is encountered in a user created PowerShell script, and the script's path is in the environment path variable, PowerShellEditorServices fails. This appears to be caused by a Newtonsoft.Json.JsonSerializationException (For additional details, see the included PowerShellEditorServices-14896.log file included below).
Because the PowerShellEditorServices is used by the PowerShell Extension for Visual Studio Code, both the extension's Command Explorer and Intellisense stop working when this exception occurs. Ideally, I feel the PowerShellEditorServices should gracefully handle and report the exception and continue running.
param ( [Parameter(Mandatory=$false)] [ValidateScript({ if ($_ -is [int] -and $_ -ge 0) { $true } else { throw "The input argument be a positive integer or zero." } })] [int]$DaysBack = 0 # Default value is 0 )
PowerShell Version
Editor Version
Installed PowerShell Extension for Visual Studio Code.
PowerShell Editor Services Version
N/A
Steps to Reproduce
In Windows 11:
Visuals
No response
Logs
PowerShellEditorServices-14896.log
StartEditorServices-14896.log
vscode-powershell.log
The text was updated successfully, but these errors were encountered: