Write-Debug Prompts for Confirmation Stopping All Script Execution When Using -Debug For Some Reason
See original GitHub issueSteps 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:
- Created 6 years ago
- Comments:13 (6 by maintainers)
Top 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 >
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 Free
Top 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
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.
@RobinWPollard For older releases, that workaround works. In PowerShell 6.2 and later though, there is no need for that workaround.