question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ConvertTo-SecureString hangs PowerShell host when run in the VS Code debugger

See original GitHub issue

If 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:open
  • Created 4 years ago
  • Reactions:1
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
TylerLeonhardtcommented, Jul 18, 2019

with “no configurations”

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.

2reactions
invisibleaxmcommented, Jul 17, 2019

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)…

Wait-Debugger
# Let's Create a Secure String :-D
$TestSecureString = "" | ConvertTo-SecureString -AsPlainText -Force

In a similar fashion, if you don’t capture the string, the debugger is able to continue, business as usual:

Wait-Debugger
# Let's Create a Secure String :-D
"Test" | ConvertTo-SecureString -AsPlainText -Force

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”

image

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found