-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Open
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
Write-Debug
and Write-Verbose
expand the -Message
where the commands should SilentlyContinue
.
Use case:
I am using a class with has a lazy evaluation (because not all results always require to be evaluated).
It concerns a recursive script where I would like to add some Write-Debug
commands, like:
Write-Debug "This takes 3 seconds $(Sleep 3)"
Expected behavior
When the -Debug
switch is omitted for my script, the script shouldn't take more time because of the debug commands.
In other words, the -Message
should not be evaluated.
Actual behavior
When the -Debug
switch is omitted for my script, the -Message
is evaluated and takes 3 secondes (for the example).
Workaround
Function test {
[CmdletBinding()] param()
if ($DebugPreference -in 'Stop', 'Continue', 'Inquire') { Write-Debug "Test $(Sleep 3)" }
}
Environment data
Name Value
---- -----
PSVersion 7.3.10
PSEdition Core
GitCommitId 7.3.10
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
Metadata
Metadata
Assignees
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.