none
Close to getting command to list all cmdlets with pipeline set to true - missing way to ignore blanks RRS feed

  • Question

  • I have the following command:

    get-command -CommandType Cmdlet | % {Get-Help $_.name -parameter * | Format-Table @{e={$_.pipelineinput -match "true"};l=$_.name} -autosize}

    It does everything I need, but, I can't quite figure out how to prevent it from returning empty lines (where the parameter in question does not contain true.  It's close but not quite there.

    Saturday, March 10, 2012 3:53 AM

Answers

  • Hi Will,

    Maybe this some help:

    Get-Command -CommandType Cmdlet | % { $cmdlet = $_.name; Get-Help $cmdlet -parameter * -ErrorAction SilentlyContinue | where {$_.pipelineInput -match "true"} | select @{l="cmdlet";e={$cmdlet}},name}

    • Marked as answer by Will Steele Saturday, March 10, 2012 12:16 PM
    Saturday, March 10, 2012 7:48 AM
  • Nice!  I've added some reformatting, expanded captioning and output table formatting to get:
     
    Get-Command -CommandType Cmdlet |
     % { $cmdlet = $_.name
         Get-Help $cmdlet -parameter * -ErrorAction SilentlyContinue |
          where {$_.pipelineInput -match "true"} |
           select @{l='Cmdlet'
                    e={$cmdlet}},
                  @{l='Property'
                    e={$_.name}},
                  @{l='Accept pipeline input by'
                    e={$_.pipelineinput -replace 'true ',''}}
       } | Format-Table -autosize
     
     
    • Marked as answer by Will Steele Saturday, March 10, 2012 5:41 PM
    Saturday, March 10, 2012 5:18 PM

All replies

  • Hi Will,

    Maybe this some help:

    Get-Command -CommandType Cmdlet | % { $cmdlet = $_.name; Get-Help $cmdlet -parameter * -ErrorAction SilentlyContinue | where {$_.pipelineInput -match "true"} | select @{l="cmdlet";e={$cmdlet}},name}

    • Marked as answer by Will Steele Saturday, March 10, 2012 12:16 PM
    Saturday, March 10, 2012 7:48 AM
  • I added one column I thought would be useful after the fact. Helpful to know which approach works.

    Get-Command -CommandType Cmdlet | `
    % { $cmdlet = $_.name; Get-Help $cmdlet -parameter * -ErrorAction SilentlyContinue | `
    where {$_.pipelineInput -match "true"} | `
    select @{l="cmdlet";e={$cmdlet}},name,@{l="By";e={$_.pipelineinput -replace 'true ',''}}}

    Thanks,

    Will

    Saturday, March 10, 2012 12:19 PM
  • Nice!  I've added some reformatting, expanded captioning and output table formatting to get:
     
    Get-Command -CommandType Cmdlet |
     % { $cmdlet = $_.name
         Get-Help $cmdlet -parameter * -ErrorAction SilentlyContinue |
          where {$_.pipelineInput -match "true"} |
           select @{l='Cmdlet'
                    e={$cmdlet}},
                  @{l='Property'
                    e={$_.name}},
                  @{l='Accept pipeline input by'
                    e={$_.pipelineinput -replace 'true ',''}}
       } | Format-Table -autosize
     
     
    • Marked as answer by Will Steele Saturday, March 10, 2012 5:41 PM
    Saturday, March 10, 2012 5:18 PM
  • Cool.  Thanks Larry.  Looks good.  I think I'm going to write up a little function.
    Saturday, March 10, 2012 5:41 PM