Question about parameters accepting pipeline input

Welcome Forums General PowerShell Q&A Question about parameters accepting pipeline input

This topic contains 2 replies, has 2 voices, and was last updated by

3 years, 8 months ago.

  • Author
  • #22839

    Points: 0
    Rank: Member

    Straight away, let me say I couldn't be more of a noob, so I apologize for the noobicity of this question.
    Just started learning Powershell using the 30 Lunches book. My question is on the topic of cmdlets accepting pipeline output.

    I've been using this handy command for a while to see what drives were mapped on a remote computer (though never having used Powershell, I just knew to copy and paste it into PS to get my results – had zero idea what was happening):

     Get-WmiObject -Class Win32_MappedLogicalDisk -ComputerName  | Select-Object -Property Name, ProviderName 

    Knowing a little more now, I'm trying to follow the process through. Here's my question: The help for Select-Object shows that its parameter "-Property" does NOT accept pipeline input. In that case, how is it acting on the objects coming through the pipe from Get-WmiObject?

    Hope that makes sense!

  • #22840

    Points: 3
    Rank: Member

    Select-Object has a parameter named -InputObject. That's what's accepting the pipeline input. The -Property parameter tells the command which properties, from the objects passed to -InputObject, to output.

    If a parameter is accepting pipeline input, you'd never see that parameter typed out. In fact, typing a parameter manually prevents it from accepting pipeline input.

  • #22845

    Points: 0
    Rank: Member

    Thank you Don!

The topic ‘Question about parameters accepting pipeline input’ is closed to new replies.