Author Posts

August 27, 2018 at 1:48 pm

I must be doing something wrong.  Hopefully someone can help.  When I try to pass the -computername parameter for Get-HotFix it only returns the local machine, but works when I use it in paranthesis for the parameter.  BTW, this is from a Month of Lunches Lab (chapter 9).  According to the help for Get-Hotfix, the computername parameter should work as pipeline input by PropertyName.


get-adcomputer -filter * | select @{n='computername';e={$}} | Get-HotFix
#This only returns objects for the domain controller (local machine)

Get-HotFix -ComputerName (select -ExpandProperty name)
#This works and returns objects for all the computers on the domain



August 27, 2018 at 2:25 pm

Are you sure on

August 27, 2018 at 2:29 pm

Looks like a bug. I can't get the second method to work either.

August 27, 2018 at 2:30 pm

Are you sure on

Get-HotFix -ComputerName (select -ExpandProperty name)

August 27, 2018 at 2:34 pm

My bad I'm working from an offline lab environment so I can't copy and paste.  The second line that works is this:

Get-HotFix -ComputerName (get-adcomputer -filter * | select -ExpandProperty name)

I'm using PSVersion 4.0 and Server 2012 with activedirectory module imported.

August 27, 2018 at 2:49 pm

Oh, I see. There's already comments on this doc that piping in computername doesn't work:

Theoretically this should work too, but it doesn't:

get-adcomputer -filter * | Get-HotFix -computername { $ } 

August 27, 2018 at 5:23 pm

-ComputerName parameter in Get-HotFix takes value from pipeline only in documentation, Actually it doesn't.
It just iterates through the list of computers specified to ComputerName.

The parameter is just defined like ValueFromPipelineByPropertyName = true

yourself can check it from the source code here. It doesn't even have a ProcessRecord() method.

just filed an issue on it.

August 27, 2018 at 7:02 pm

I'm kinda new to PowerShell but in line one if you are passing a variable "computername" it should have a $ in front and also in double quotes "" instead of single quotes to allow it to use what is stored.


Hope this helps.

August 27, 2018 at 8:37 pm

That's actually right. It's a hash table to make a custom property with select-object.

PS C:\users\superuser> get-process chrome | select-object @{n='myname';e={$}}