Skip to content

Feature request: Add -VerboseVariable and -DebugVariable common paramaters #6702

Closed

Description

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.

Activity

  1. BrucePay commented on Apr 23, 2018

    @BrucePay
    Collaborator

    Mark Kraus (@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)

  2. markekraus commented on Apr 23, 2018

    @markekraus
    ContributorAuthor

    Bruce Payette (@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:

  3. bstrautin commented on Aug 10, 2018

    @bstrautin

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

  4. ThomasNieto commented on May 31, 2019

    @ThomasNieto
    Contributor

    Steve Lee (@SteveL-MSFT) can this enhancement be added to PS 7?

  5. SteveL-MSFT commented on Jul 25, 2019

    @SteveL-MSFT
    Member

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

  6. KirkMunro commented on Jul 25, 2019

    @KirkMunro
    Contributor

    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?

  7. vexx32 commented on Jul 25, 2019

    @vexx32
    Collaborator

    👀 do iiiit

  8. KirkMunro commented on Jul 26, 2019

    @KirkMunro
    Contributor

    Rain Sallow (/u/ta11ow) (@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.

  9. jantari commented on Feb 3, 2022

    @jantari

    Is this still happening anytime?

    I want to be able to run a command that produces quite a bit of verbose and/or debug output and capture BOTH those streams to a file for later reference. I do not want these streams in the main output (transcript) of the command because they are lengthy and really spam the otherwise concise transcript with tons of information that is only needed very very rarely.

    I basically want to be able to do:

    # This errors because details.log is locked / already in use
    Invoke-ExampleCmdlet -Parameter "value" -Verbose -Debug 4>details.log 5>details.log

    or

    # This fails for absolutely no reason really, I guess redirecting streams to anything other
    # than 1, 2 or null was just never implemented because ..... ????
    Invoke-ExampleCmdlet -Parameter "value" -Verbose -Debug 5>&4 4>details.log

    or at least:

    Invoke-ExampleCmdlet -Parameter "value" -Verbose -Debug -VerboseVariable details_verbose -DebugVariable details_debug

    although that last option would of course result in separately captured streams so the order of the output cannot be reconstructed. But at least it's something.

  10. jantari commented on Nov 16, 2023

    @jantari

    I still want this.

  11. microsoft-github-policy-service commented on Nov 24, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreWG-Cmdletsgeneral cmdlet issues

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions