vscode-powershell
vscode-powershell copied to clipboard
Getting ParseException when opening PowerShell extension terminal in VS code.
Prerequisites
- [X] I have written a descriptive issue title.
- [X] I have searched all open and closed issues to ensure it has not already been reported.
- [X] I have read the troubleshooting guide.
- [X] I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
- [X] I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
- [X] If this is a security issue, I have read the security issue reporting guidance.
Summary
I am experiencing a problem when my Visual Studio Code PowerShell Extension Terminal starts.
I am receiving the following error:
ParseException: At line:3 char:141
+ … l' -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The string is missing the terminator: '.
at System.Management.Automation.ScriptBlock.Create(Parser parser, String fileName, String fileContents)
at System.Management.Automation.ScriptBlock.Create(ExecutionContext context, String script)
at System.Management.Automation.CommandInvocationIntrinsics.InvokeScript(String script)
at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.PsHelpers.RunScript[T](CommandInvocationIntrinsics cii, String script)
at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.PsExtensions.RunScript[T](PSCmdlet cmdlet, String script)
at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.PsHelpers.GetScriptCmdlets(PSCmdlet cmdlet, String scriptFolder)
at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.GetScriptCmdlet.ProcessRecord()
The error prints itself multiple times when the PowerShell Extension terminal window opens up. It still allows me to run cmdlets, but I would like to understand the cause of this issue.
I am uncertain whether this issue presents itself since I have an apostrophe (') in my name, so I tried moving my OneDrive folder to another path without the apostrophe. This did not solve my issue.
In the regular PowerShell terminal (pwsh) I am not receiving this error.
PowerShell Version
PS C:\Users\<user>\OneDrive - <companyname>\<companyname>\VSCodeFiles\LocalVSCProjects> $PSVersionTable; $Host
Name Value
---- -----
PSVersion 7.4.3
PSEdition Core
GitCommitId 7.4.3
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Name : Visual Studio Code Host
Version : 2024.2.2
InstanceId : fb00f15d-def3-4e93-b4ac-ed32b9306f59
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : da-DK
CurrentUICulture : en-GB
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled : True
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace
Visual Studio Code Version
PS C:\Users\<user>\OneDrive - <companyname>\<companyname>\VSCodeFiles\LocalVSCProjects> code --version
1.90.2
5437499feb04f7a586f677b155b039bc2b3669eb
x64
Extension Version
PS C:\Users\<user>\OneDrive - <companyname>\<companyname>\VSCodeFiles\LocalVSCProjects> code --list-extensions --show-versions | Select-String powershell
[email protected]
Steps to Reproduce
No code execution is required. The error occurs on startup of the terminal window of the PowerShell extension. Below is the full error.
PS C:\Users\sean\OneDrive - <redacted>\<redacted>\VSCodeFiles\LocalVSCProjects> ParseException: At line:3 char:141
+ … l' -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The string is missing the terminator: '.
at System.Management.Automation.ScriptBlock.Create(Parser parser, String fileName, String fileContents)
at System.Management.Automation.ScriptBlock.Create(ExecutionContext context, String script)
at System.Management.Automation.CommandInvocationIntrinsics.InvokeScript(String script)
at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.PsHelpers.RunScript[T](CommandInvocationIntrinsics cii, String script)
at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.PsExtensions.RunScript[T](PSCmdlet cmdlet, String script)
at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.PsHelpers.GetScriptCmdlets(PSCmdlet cmdlet, String scriptFolder)
at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.GetScriptCmdlet.ProcessRecord()
ParseException: At line:3 char:141
+ … l' -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The string is missing the terminator: '.
at System.Management.Automation.ScriptBlock.Create(Parser parser, String fileName, String fileContents)
at System.Management.Automation.ScriptBlock.Create(ExecutionContext context, String script)
at System.Management.Automation.CommandInvocationIntrinsics.InvokeScript(String script)
at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.PsHelpers.RunScript[T](CommandInvocationIntrinsics cii, String script)
at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.PsExtensions.RunScript[T](PSCmdlet cmdlet, String script)
at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.PsHelpers.GetScriptCmdlets(PSCmdlet cmdlet, String scriptFolder)
at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.GetScriptCmdlet.ProcessRecord()
ParseException: At line:3 char:139
+ … m' -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The string is missing the terminator: '.
at System.Management.Automation.ScriptBlock.Create(Parser parser, String fileName, String fileContents)
at System.Management.Automation.ScriptBlock.Create(ExecutionContext context, String script)
at System.Management.Automation.CommandInvocationIntrinsics.InvokeScript(String script)
at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.PsHelpers.RunScript[T](CommandInvocationIntrinsics cii, String script)
at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.PsExtensions.RunScript[T](PSCmdlet cmdlet, String script)
at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.PsHelpers.GetScriptCmdlets(PSCmdlet cmdlet, String scriptFolder)
at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.GetScriptCmdlet.ProcessRecord()
ParseException: At line:3 char:142
+ … s' -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The string is missing the terminator: '.
at System.Management.Automation.ScriptBlock.Create(Parser parser, String fileName, String fileContents)
at System.Management.Automation.ScriptBlock.Create(ExecutionContext context, String script)
at System.Management.Automation.CommandInvocationIntrinsics.InvokeScript(String script)
at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.PsHelpers.RunScript[T](CommandInvocationIntrinsics cii, String script)
at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.PsExtensions.RunScript[T](PSCmdlet cmdlet, String script)
at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.PsHelpers.GetScriptCmdlets(PSCmdlet cmdlet, String scriptFolder)
at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.GetScriptCmdlet.ProcessRecord()
ParseException: At line:3 char:142
+ … s' -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The string is missing the terminator: '.
at System.Management.Automation.ScriptBlock.Create(Parser parser, String fileName, String fileContents)
at System.Management.Automation.ScriptBlock.Create(ExecutionContext context, String script)
at System.Management.Automation.CommandInvocationIntrinsics.InvokeScript(String script)
at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.PsHelpers.RunScript[T](CommandInvocationIntrinsics cii, String script)
at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.PsExtensions.RunScript[T](PSCmdlet cmdlet, String script)
at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.PsHelpers.GetScriptCmdlets(PSCmdlet cmdlet, String scriptFolder)
at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.GetScriptCmdlet.ProcessRecord()
Visuals
No response
Logs
No response
Hi,
Please open an issue with Azure PowerShell as the stack trace you shared shows its emanating from their code:
Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell
I'm going to guess you're probably right about the apostrophe in your name, so share that with them as well. As to why it's happening on start-up of the extension, I can only surmise you're loading the Azure PowerShell module in your profile, or having it installed has injected some startup sequence.
But the PowerShell extension for VS Code does not ship nor load the Azure PowerShell module.
Cheers!
This issue has been labeled as resolved, please verify the provided fix (or other reason).
This issue has been labeled as needing fix verification and has not had any activity a week. It has been closed for housekeeping purposes.
I'm experiencing the same problem as of 10-17-2024. My name also has an apostrophe (O'Neill). This just began recently, is it possible the bug has been reintroduced in recent builds?
@JONeillSr as noted above, the issue occurs in Azure PowerShell and not the vscode module, you'd have to ask them :)
I fixed the issue by uninstalling the Microsoft.Graph module, logging in as a different user that doesn’t have an apostrophe in the username, installing the Microsoft.Graph module again using the AllUsers scope, then logging back in with my original user account. Started VSCode with no errors this time within the POSH extension.
On Oct 17, 2024, at 2:20 PM, Justin Grote @.***> wrote:
@JONeillSrhttps://github.com/JONeillSr as noted above, the issue occurs in Azure PowerShell and not the vscode module, you'd have to ask them :)
— Reply to this email directly, view it on GitHubhttps://github.com/PowerShell/vscode-powershell/issues/5010#issuecomment-2420232701, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGGIP3KCHFIOCCBXTZ4UOWTZ375VJAVCNFSM6AAAAABJ7UCHN6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRQGIZTENZQGE. You are receiving this because you were mentioned.Message ID: @.***>