ConvertTo-SecureString hangs PowerShell host when run in the VS Code debugger
See original GitHub issueIf you run the below code without using Wait-Debugger then it will run correctly without issue:
param($Request, $TriggerMetadata)
Wait-Debugger
$EncryptString = "eamon"
Write-Output $EncryptString
$TestSecure = ConvertTo-SecureString -String $EncryptString -AsPlainText -Force
$TestSecure
If you run it with Wait-Debugger enabled, it will not complete and hang in VSCode.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:11 (6 by maintainers)
Top Results From Across the Web
ConvertTo-SecureString hangs PowerShell host when run ...
ConvertTo-SecureString hangs PowerShell host when run in the VS Code debugger within a local Azure Function host #2050.
Read more >VsCode hangs/freezes with "Starting up powershell" in ...
Confirm that all Powershell processes are terminated in the relevant OS, eg Task Manager in windows. Start VsCode running as Admin.
Read more >PowerShell Form Hangs on API Connection
When I run the commands manually through a console, it works fine. Everything happens as expected, I get the connection and I can...
Read more >Debugging PowerShell script in Visual Studio Code – Part 1
Press Ctrl+Shift+P (Cmd+Shift+P on Mac) to open the PowerShell extension's Examples folder, type PowerShell open examples, and then press Enter.
Read more >al test runner – Page 2 – James Pearson
Attaching the debugger and running a test from VS Code ... Development capability of VS Code to open a terminal and execute PowerShell...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This just means it launches the script and runs it in the Integrated Console below with debugging.
From my experience, this issue only serviced in the attach debugging scenario.
One more piece of info to expand on the example provided by @ZanattaMichael as I think this could be related to assignment of a secure string vs the actual converto-securestring cmdlet ? Take for example the following slightly modified scenarios which are both working inside azure functions / debugged locally:
This example has an error (empty string), however the debugger is able to continue onto next line (it just complains about the empty string)…
In a similar fashion, if you don’t capture the string, the debugger is able to continue, business as usual:
The weird thing is that the code provided by @eamonoreilly and @ZanattaMichael is working just fine when debugged in vscode using the same powershell extension with “no configurations”