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
To be 100% honest, I don't know if this is a bug, a design choice or is outside the scope of the PS extension.
When pressing F5 to run a script, the PS VS Code extension uses double quotes around the script's path. This presents an issue if there is a $ anywhere in the path (e.g. C:\Scripts\Test$myScript\Get-ScriptPath.ps1) as variable expansion takes place when it shouldn't.
# Pressing F5 in VS Code uses double quotes around the script's path and breaks if the path name contains a $
PS C:\> . "c:\Scripts\Test$myScript\Get-ScriptPath.ps1"
.: The term 'c:\Scripts\Test\Get-ScriptPath.ps1' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
# Dot-sourcing with manually added single quotes works
PS C:\> . 'c:\Scripts\Test$myScript\Get-ScriptPath.ps1'
This script's path is: C:\Scripts\Test$myScript\Get-ScriptPath.ps1
# Tabbing/autocompleting a script's path works (in VS console, pwsh.exe and PowerShell.exe)
PS C:\> & 'C:\Scripts\Test$myScript\Get-ScriptPath.ps1'
This script's path is: C:\Scripts\Test$myScript\Get-ScriptPath.ps1
Within the VS Code PS console, (or pwsh.exe or PowerShell.exe) if I tab/autocomplete a script's location, it will add the call operator & and automatically add single quotes around a path with spaces or a $.
PowerShell Version
PS C:\> $PSVersionTableName Value---- -----PSVersion 7.2.7PSEdition CoreGitCommitId 7.2.7OS Microsoft Windows 10.0.19045Platform Win32NTPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}PSRemotingProtocolVersion 2.3SerializationVersion 1.1.0.1WSManStackVersion 3.0
In VS Code, press F5 to run a PowerShell script that's inside a folder containing a $ in the path name
(e.g. C:\Scripts\Test$myScript\Get-ScriptPath.ps1)
Visuals
No response
Logs
No response
The text was updated successfully, but these errors were encountered:
Prerequisites
Summary
To be 100% honest, I don't know if this is a bug, a design choice or is outside the scope of the PS extension.
When pressing F5 to run a script, the PS VS Code extension uses double quotes around the script's path. This presents an issue if there is a
$
anywhere in the path (e.g.C:\Scripts\Test$myScript\Get-ScriptPath.ps1
) as variable expansion takes place when it shouldn't.Within the VS Code PS console, (or pwsh.exe or PowerShell.exe) if I tab/autocomplete a script's location, it will add the call operator
&
and automatically add single quotes around a path with spaces or a$
.PowerShell Version
Visual Studio Code Version
Extension Version
Steps to Reproduce
In VS Code, press F5 to run a PowerShell script that's inside a folder containing a
$
in the path name(e.g.
C:\Scripts\Test$myScript\Get-ScriptPath.ps1
)Visuals
No response
Logs
No response
The text was updated successfully, but these errors were encountered: