Powershell: Feature request: Add -VerboseVariable and -DebugVariable common paramaters

Created on 23 Apr 2018  路  8Comments  路  Source: PowerShell/PowerShell

I have often run into the need to capture output from Write-Verbose and Write-Debug. I know that it can currently be done by using subexpressions and output redirection. Those methods are not quite as user friendly as -OutVariable, -InformationVariable, -ErrorVaraiable, and -WarningVariable. I'm sure there was a good reason for not including -DebugVariable and -VerboseVariable, but I'm curious if these could be added.

Area-Cmdlets-Core Issue-Enhancement

Most helpful comment

@vexx32 I'm about half way there. Working out kinks from the first pass through the code. That plus Pester tests on deck for tomorrow morning.

All 8 comments

@markekraus IIRC I don't think we saw a need to capture this stuff since it's transient execution information (which you can record with transcript). I'm curious - what are the cases where you find you need it? (I'm not objecting to adding these parameters - it shouldn't be hard, I'm just curious)

@BrucePay Honestly, it's more often Write-Verbose and I've never really needed this for Write-Debug. But much of it is about UX testing (i.e. making sure -Verbose on certain commands actually return something). The other use case is just general "capture all the outputs" for selective verbose logging (where you want all the output streams captured for some commands but not all).

There have even been times in the Web Cmdlets tests where we are using the Verbose stream to ensure certain code paths are being hit when it is not obvious or possible to derive from command output or behavior. For example, this test function:
https://github.com/PowerShell/PowerShell/blob/2da75767365c7136877b53339aec7b372acf16d6/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1#L266

Apparently at least one person has a real-world use for this: Reddit thread

@SteveL-MSFT can this enhancement be added to PS 7?

@tnieto88 this is currently not a priority for PS7. We would welcome a PR from the community however :)

This is related to the need for -VerboseAction and -DebugAction as well, as mentioned in this set of RFCs. Can I add the lot of them?

馃憖 _do iiiit_

@vexx32 I'm about half way there. Working out kinks from the first pass through the code. That plus Pester tests on deck for tomorrow morning.

Was this page helpful?
0 / 5 - 0 ratings