Description
Prerequisites
- 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 like to run PowerShell scripts into external windows. I have been using the same launch configs for years now without problem, but suddenly none of them now work. Here is an example launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "PowerShell",
"request": "launch",
"name": "PS5",
"script": "Start-Process",
"args": [
"-FilePath ($Env:SystemRoot + '\\system32\\WindowsPowerShell\\v1.0\\powershell.exe')",
"-Argumentlist '-NoExit -NoProfile -ExecutionPolicy Bypass -File \"${file}\"'"
]
}
]
}
What should happen when running launching a .PS1 file with the debug option, is this:
PS C:\Test> Start-Process -FilePath ($Env:SystemRoot + '\system32\WindowsPowerShell\v1.0\powershell.exe') -Argumentlist '-NoExit -NoProfile -ExecutionPolicy Bypass -File "c:\Users\TestUser\desktop\TestScript.PS1"'
However it actually runs:
PS C:\Test> C:\Test\Start-Process -FilePath ($Env:SystemRoot + '\system32\WindowsPowerShell\v1.0\powershell.exe') -Argumentlist '-NoExit -NoProfile -ExecutionPolicy Bypass -File "c:\Users\TestUser\desktop\TestScript.PS1"'
Which of course leads to the error message:
C:\Test\Start-Process: The term 'C:\Test\Start-Process' is not recognized as a name of a cmdlet, function, script file, or executable program.
PowerShell Version
Name Value
---- -----
PSVersion 7.1.4
PSEdition Core
GitCommitId 7.1.4
OS Microsoft Windows 10.0.19042
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.59.1
3866c3553be8b268c8a7f8c0482c0c0177aa8bfa
x64
Extension Version
ms-vscode.powershell-preview@2021.8.2
Steps to Reproduce
Use the Launch config from above, and select it as the debug option. Then attempt to run any SAVED script.
Visuals
No response
Logs
No response