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.

Write-Debug Prompts for Confirmation Stopping All Script Execution When Using -Debug For Some Reason

See original GitHub issue

Steps to reproduce

Save this to a file with a .ps1 extension and run it

function Test-DebugMessage
{
     [CmdletBinding()]
     [OutputType()]

     param ()

     process
     {
         Write-Debug ( 'Test Message' )
     }
}

Test-DebugMessage -Debug

Expected behavior

The following message is emitted

DEBUG: Test Message

Actual behavior

Prompted to continue for every Write-Debug statement. A for “Yes to All” does nothing

DEBUG: Test Message

Confirm
Continue with this operation?
[Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"): a

Environment data

> $PSVersionTable.GetEnumerator() | ForEach-Object { Write-Host ('{0,26} : {1,-20}' -f $PSItem.Key,($PSItem.Value -join ', ') ) }
                 PSVersion : 5.1.15063.674
                 PSEdition : Desktop
      PSCompatibleVersions : 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.15063.674
              BuildVersion : 10.0.15063.674
                CLRVersion : 4.0.30319.42000
         WSManStackVersion : 3.0
 PSRemotingProtocolVersion : 2.3
      SerializationVersion : 1.1.0.1

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
HQJaTucommented, Jun 20, 2019

Thanks for that @KirkMunro. Since the pre 6.2 behaviour was very annoying, I simply upgraded to 6.2.1 and continued working with much less friction.

0reactions
KirkMunrocommented, Jun 7, 2019

@RobinWPollard For older releases, that workaround works. In PowerShell 6.2 and later though, there is no need for that workaround.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prevent Write-Debug From Bugging You | Learn Powershell
As soon as I run this function with the –Debug statement, I will see a confirmation prompt for each and every Write-Debug that...
Read more >
debug requesting confirmation
It sounds like your $DebugPreference variable is set to 'Inquire'. From Get-Help about_preference_variables:
Read more >
Fun With PowerShell Write-Debug
You can see our debug message was displayed, then we got a message to let us know the debug preference was set to...
Read more >
about Preference Variables - PowerShell
The preference variables affect the PowerShell operating environment and all commands run in the environment. Some cmdlets have parameters ...
Read more >
Quick and Efficient PowerShell Script Debugging with ...
Breakpoints can be created in PowerShell in one of two ways: by using the Write-Debug cmdlet, or by using the Set-PsBreakPoint cmdlet.
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