PowerShell/ConsoleGuiTools

PassThru command doesn't excist

Opened this issue · 2 comments

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Steps to reproduce

when doing
$list | Out-ConsoleGridView -PassThru | Export-CSV C:\Temp\test.csv

Expected behavior

I expect it to do PassTru like Out-GridView and like it's mentioned in README.md Example 7: https://github.com/PowerShell/ConsoleGuiTools?tab=readme-ov-file#example-7-pass-multiple-items-through-out-consolegridview

Actual behavior

it gives the error
`Out-ConsoleGridView: A parameter cannot be found that matches parameter name 'PassTru'.`

Error details

Exception             : 
    Type              : System.Management.Automation.ParameterBindingException
    Message           : A parameter cannot be found that matches parameter name 'PassTru'.
    ParameterName     : PassTru
    ErrorId           : NamedParameterNotFound
    Line              : 1
    Offset            : 329
    CommandInvocation : 
        MyCommand        : Out-ConsoleGridView
        BoundParameters  : 
            Comparer : System.OrdinalIgnoreCaseComparer
            Count    : 1
            Keys     : 
                              Title
            Values   : 
                              Gedetailleerde licenties
            SyncRoot : 
                Comparer : System.OrdinalIgnoreCaseComparer
                Count    : 1
                Keys     : 
                                      Title
                Values   : 
                                      Gedetailleerde licenties
                SyncRoot : 
                    Comparer : System.OrdinalIgnoreCaseComparer
                    Count    : 1
                    Keys     : 
                                              Title
                    Values   : 
                                              Gedetailleerde licenties
                    SyncRoot : 
                        Comparer : System.OrdinalIgnoreCaseComparer
                        Count    : 1
                        Keys     : 
                                                      Title
                        Values   : 
                                                      Gedetailleerde licenties
                        SyncRoot : 
                            Comparer : System.OrdinalIgnoreCaseComparer
                            Count    : 1
                            Keys     : 
                                                              Title
                            Values   : 
                                                              Gedetailleerde licenties
                            SyncRoot : 
                                Comparer : System.OrdinalIgnoreCaseComparer
                                Count    : 1
                                Keys     : 
                                                                      Title
                                Values   : 
                                                                      Gedetailleerde licenties
                                SyncRoot : 
                                    Comparer : System.OrdinalIgnoreCaseComparer
                                    Count    : 1
                                    Keys     : …
                                    Values   : …
                                    SyncRoot : …
        ScriptLineNumber : 1
        OffsetInLine     : 275
        HistoryId        : 156
        Line             : $devices | Sort-Object -Property "Protection Plan", deviceclass, longname | Select-Object "Protection Plan", deviceclass, longname, lastLoggedInUser,  
@{ name = 'Organisation Name' ; expr = { if ($_.orgUnitId -eq $_.customerId) { $_.customerName } else { $_.siteName } } } | Out-ConsoleGridView -Title "Gedetailleerde licenties" 
 -PassTru
        Statement        : Out-ConsoleGridView -Title "Gedetailleerde licenties" -PassTru
        PositionMessage  : At line:1 char:275
                           + … ame } } } | Out-ConsoleGridView -Title "Gedetailleerde licenties" -Pa …
                           +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        InvocationName   : Out-ConsoleGridView
        PipelineLength   : 3
        PipelinePosition : 3
        ExpectingInput   : True
    ErrorRecord       : 
        Exception             : 
            Type    : System.Management.Automation.ParentContainsErrorRecordException
            Message : A parameter cannot be found that matches parameter name 'PassTru'.
            HResult : -2146233087
        CategoryInfo          : InvalidArgument: (:) [Out-ConsoleGridView], ParentContainsErrorRecordException
        FullyQualifiedErrorId : NamedParameterNotFound,OutGridView.Cmdlet.OutConsoleGridViewCmdletCommand
        InvocationInfo        : 
            MyCommand        : Out-ConsoleGridView
            ScriptLineNumber : 1
            OffsetInLine     : 329
            HistoryId        : 156
            Line             : $devices | Sort-Object -Property "Protection Plan", deviceclass, longname | Select-Object "Protection Plan", deviceclass, longname, lastLoggedInUs 
er, @{ name = 'Organisation Name' ; expr = { if ($_.orgUnitId -eq $_.customerId) { $_.customerName } else { $_.siteName } } } | Out-ConsoleGridView -Title "Gedetailleerde licent 
ies" -PassTru
            Statement        : -PassTru
            PositionMessage  : At line:1 char:329
                               + …  } } | Out-ConsoleGridView -Title "Gedetailleerde licenties" -PassTru
                               +                                                                ~~~~~~~~
            CommandOrigin    : Internal
        ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
    TargetSite        : 
        Name          : VerifyArgumentsProcessed
        DeclaringType : [System.Management.Automation.CmdletParameterBinderController]
        MemberType    : Method
        Module        : System.Management.Automation.dll
    Data              : System.Collections.ListDictionaryInternal
    Source            : System.Management.Automation
    HResult           : -2146233087
    StackTrace        : 
   at System.Management.Automation.CmdletParameterBinderController.VerifyArgumentsProcessed(ParameterBindingException originalBindingException)
   at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments)
   at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)
   at System.Management.Automation.CommandProcessor.BindCommandLineParameters()
   at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)
   at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)
   at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
   at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
--- End of stack trace from previous location ---
   at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
   at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, Com 
mandRedirection[][] commandRedirections, FunctionContext funcContext)
   at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
CategoryInfo          : InvalidArgument: (:) [Out-ConsoleGridView], ParameterBindingException
FullyQualifiedErrorId : NamedParameterNotFound,OutGridView.Cmdlet.OutConsoleGridViewCmdletCommand
InvocationInfo        : 
    MyCommand        : Out-ConsoleGridView
    ScriptLineNumber : 1
    OffsetInLine     : 329
    HistoryId        : 156
    Line             : $devices | Sort-Object -Property "Protection Plan", deviceclass, longname | Select-Object "Protection Plan", deviceclass, longname, lastLoggedInUser, @{ n 
ame = 'Organisation Name' ; expr = { if ($_.orgUnitId -eq $_.customerId) { $_.customerName } else { $_.siteName } } } | Out-ConsoleGridView -Title "Gedetailleerde licenties" -Pa 
ssTru
    Statement        : -PassTru
    PositionMessage  : At line:1 char:329
                       + …  } } | Out-ConsoleGridView -Title "Gedetailleerde licenties" -PassTru
                       +                                                                ~~~~~~~~
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.5
PSEdition                      Core
GitCommitId                    7.4.5
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

0.7.7

Visuals

No response

Never mind, with the default of multiselect. it was possible to also select nothing.
I had a logic that if you "Enter" it would create an export to excel, if you "Esc" it would not.
but with an enforced "-OoutputMode Single", I can mimic this behaviour

So the only thing that needs changing is maybe Example 7 of README.md

I've made a Pull Request to fix this #255