"script" configuration in launch.json behavior no longer runs a cmdlet.
See original GitHub issuePrerequisites
- I have written a descriptive issue title.
- I have searched all issues to ensure it has not already been reported.
- I have read the troubleshooting guide.
- I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
Summary
I have been using a launch.json configuration for a couple years to run my active script in a new, external PowerShell window. Recently, this has broken. It’s obvious from the text in the console that the working folder is being stuck onto the front of the value in the “script” setting as though it assumes the value is a .ps1 file in the local folder instead of a cmdlet that’s been working forever.
This is the configuration section: { “name”: “Run in External PowerShell Window - v5”, “type”: “PowerShell”, “request”: “launch”, “script”: “Start-Process”, “args”: [ “-FilePath ($Env:SystemRoot + ‘\system32\WindowsPowerShell\v1.0\powershell.exe’)”, “-Argumentlist ‘-NoExit -ExecutionPolicy Bypass -File "${file}"’” ], “cwd”: “${file}” },
PowerShell Version
Name Value
---- -----
PSVersion 5.1.19041.1151
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.1151
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Visual Studio Code Version
1.60.0
e7d7e9a9348e6a8cc8c03f877d39cb72e5dfb1ff
x64
Extension Version
ms-vscode.powershell@2021.8.2
Steps to Reproduce
-
Create a PowerShell script to do something simple such as running Get-Process.
-
Save it into a folder.
-
Open the folder in VS Code .
-
Create a launch.json configuration with these settings: { “version”: “0.2.0”, “configurations”: [ { “name”: “PowerShell: Launch Current File”, “type”: “PowerShell”, “request”: “launch”, “script”: “${file}”, “cwd”: “${file}” }, { “name”: “Run in External PowerShell Window - v5”, “type”: “PowerShell”, “request”: “launch”, “script”: “Start-Process”, “args”: [ “-FilePath ($Env:SystemRoot + ‘\system32\WindowsPowerShell\v1.0\powershell.exe’)”, “-Argumentlist ‘-NoExit -ExecutionPolicy Bypass -File "${file}"’” ], “cwd”: “${file}” } ] }
-
Go to the debugging panel and select the option for “Run in External PowerShell Window - v5”.
-
Hit F5.
-
Look in the terminal window for the error.
Visuals
No response
Logs
I tried setting logging to Diagnostic and to Verbose, but no log folder was created beneath $HOME.vscode\extensions.ms-vscode.powershell-1.9.0. I suspect this may be because I’m trying to launch in an external window.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
I have tested it on two different machines, across four different configurations that rely on the same capability and all were successful. Thank you.
Closing bug report.
So sorry… can you link me to instructions to install the preview of the extension? I’d love to test it.