Skip to content

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

@RickFlist

Description

@RickFlist

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-By DesignThe reported behavior is by design.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions