Problem accepting pipeline input byPropertyName

Welcome Forums General PowerShell Q&A Problem accepting pipeline input byPropertyName

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

1 year, 12 months ago.

  • Author
  • #64954

    Points: 0
    Rank: Member

    I'm running through some lab questions in Posh MOL 3rd Edition, and specifically trying to get the following command to work. All that happens is it grabs the hotfixes on my local machine;

    get-adcomputer -Filter * | select -Property @{n='computername';e={$}} | get-hotfix

    Get-hotfix's help says it accepts a "computername" parameter from pipeline byPropertyName, yet my command above fails to give me the list of hotfixes for each computer, as I'd expect. what gives?

    I am on a domain, and I can contact the adcomputers. Furthermore, backing up a step to the pipeline preceding "get-hotfix", the .count() method shows me that I have 233 objects (of type adcomputer) in the pipeline. So it's something to do with how get-hotfix is handling multiple objects (I think?).

    I just don't get it, and the computername parameter definitely accepts an array too.

    NB: I noticed somebody else ran into this (, but the article doesn't really give a definitive answer which I can tell.

    I'm either completely misunderstanding how the pipeline process works, or there's something else at play here.

    Really hoping somebody will be able to help me find an answer.

    Many thanks

  • #64977

    Points: 706
    Helping Hand
    Rank: Major Contributor

    You can help Get-Hotfix to determine what parameterset you want to use by specifying the paramter name ....
    Try this:

    Get-HotFix -ComputerName $(Get-ADComputer -Filter * |  select -ExpandProperty name )

    But this could take a while and could throw some errors when some of the computers are not available.

    • #64980

      Points: 0
      Rank: Member

      Thanks Olaf, but unfortunately the lab question specified not to use parenthesis; rather it should use the pipeline. Furthermore, as stated, the help for get-hotfix clearly states that the computername parameter accepts pipeline input byPropertyName. Multiple objects (arrays) allowed too.

      I need to know that I'm understanding the pipeline properly, and that it works as expected.

  • #65026

    Points: 1
    Rank: Member

    Is it a bug? If not, I don't understand it. With Stop-Process, another cmdlet that takes pipeline input by property, I can pass an object or a collection of objects with a "Name" property.

        [PSCustomObject] @{ Name = "Process1" }
        [PSCustomObject] @{ Name = "Process2" }
        [PSCustomObject] @{ Name = "Process3" }
    ) | Stop-Process

    This works, but trying a similar approach with Get-HotFix doesn't (at least in PowerShell 4.0).

        [PSCustomObject] @{ ComputerName = "COMPUTER1" }
        [PSCustomObject] @{ ComputerName = "COMPUTER2" }
        [PSCustomObject] @{ ComputerName = "COMPUTER3" }
    ) | Get-HotFix

    The command runs with no errors, but instead of processing the objects it seems to return results for the local computer instead.

    • #65031

      Points: 0
      Rank: Member

      Hey @dudebro. Many thanks for the reply.

      I think it might well be. However, the reason I was questioning myself was the fact that it was in one of the Lab questions for Powershell in a Month of Lunches 3rd Edition, and confirmed as valid.

      Ex: Get-ADComputer -filter * | Select-Object @{l='computername';e={$}} | Get-Hotfix

      I too am able to get this working with process objects and creating an aduser(s), in-line with your example methods; just not when piping to the get-hotfix cmdlet.

      Whilst I think it must be a bug, it would be good to get one of the authors' view on it, just to confirm either way.

      Are you seeing this @DonJones / @jeffhicks?

  • #65053

    Points: 1
    Rank: Member

    @Longjohn, see Don Jones' @donj reply to same topic on a different post.

    Help! Custom properties and piping

    • #65088

      Points: 0
      Rank: Member

      @curtissmith Many thanks for pointing this out. I'll be sure to search the forum first next time 😉


The topic ‘Problem accepting pipeline input byPropertyName’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort