Question about parameters accepting pipeline input

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of James Fox James Fox 1 year, 9 months ago.

  • Author
    Posts
  • #22839
    Profile photo of James Fox
    James Fox
    Participant

    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!
    James

  • #22840
    Profile photo of Don Jones
    Don Jones
    Keymaster

    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
    Profile photo of James Fox
    James Fox
    Participant

    Thank you Don!

You must be logged in to reply to this topic.