# Help! Custom properties and piping

**URL:** <https://forums.powershell.org/t/help-custom-properties-and-piping/2247>\
**Category:** PowerShell Help\
**Created:** [February 5, 2014, 2:58am UTC](https://forums.powershell.org/t/help-custom-properties-and-piping/2247 "2014-02-05T02:58:30Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![leonard-kong](https://avatars.discourse-cdn.com/v4/letter/l/96bed5/32.png) [@leonard-kong](https://forums.powershell.org/u/leonard-kong)\
**Post date:** [February 5, 2014, 2:58am UTC](https://forums.powershell.org/t/help-custom-properties-and-piping/2247/1 "2014-02-05T02:58:30Z")

</div>

Hi Guys,

Pretty new to powershell here and was just learning it using the Morelunches book on Powershell and came upon one of the labs in chapter 9 that got me a bit confused. The commands are supposed to filter out computers on the domain and retrieve all hot-fixes on them. In the lab, it says that the follow command lines are supposed to be equivalent but when I run the second string, it only reports the hotfixes on the local machine… Can anyone shed some light on why this is?

First command:

```
Get-Hotfix -computerName (get-adcomputer -filter * | Select-Object -expand name)
```

Second command:

```
get-adcomputer -filter * | Select-Object @{l='computername';e={$_.name}} | Get-Hotfix
```

Thanks in advance for all your help!!  
Leonard

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [February 5, 2014, 4:16am UTC](https://forums.powershell.org/t/help-custom-properties-and-piping/2247/2 "2014-02-05T04:16:54Z")

</div>

There’s a kinda-bug in the Get-Hotfix documentation; it turns out it won’t accept pipeline input, although the original docs tag it as doing so. So in theory both commands work, but in practice you have to do the first one because the cmdlet doesn’t accept pipeline input as advertised.

---

<div class="post-metadata">

**Author:** ![leonard-kong](https://avatars.discourse-cdn.com/v4/letter/l/96bed5/32.png) [@leonard-kong](https://forums.powershell.org/u/leonard-kong)\
**Post date:** [February 5, 2014, 4:43am UTC](https://forums.powershell.org/t/help-custom-properties-and-piping/2247/3 "2014-02-05T04:43:09Z")

</div>

Ahh. No wonder! That left me scratching my head a bit. That’s good to know. Is there any place where I would have been able to find this information on my own or am I pretty much limited to googling “Get-hotfix pipeline input”?

Also, it hasn’t really mentioned it in the book so far, so I figure I’ll ask here. In the second command line what does this part of the it do exactly?

```
@{l='computername';e={e={$_.name}}
```

I know it’s general function is to create a custom object with the computername property so that Get-Hotfix (if it worked correctly) would accept the parameter through it’s pipeline, but I was hoping you could break down each part of that line so I could understand it better…

Thanks again for your help!

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [February 5, 2014, 4:58am UTC](https://forums.powershell.org/t/help-custom-properties-and-piping/2247/4 "2014-02-05T04:58:10Z")

</div>

Oddly, the documentation for Get-Hotfix mentions this anomaly. You’d just have to read the full help file.

That is a hash table. The technique is actually described in the first Lunches book. In this case, it’s being used with Select-Object to create a new property named ComputerName that contains the value from the input object’s Name property. Similar examples are in the help file for Select-Object. There’s a pretty descriptive breakdown in “Learn PowerShell 3 in a Month of Lunches,” as I use the technique pretty extensively in that book. It’s also used with Format-Table, for example.

---

<div class="post-metadata">

**Author:** ![leonard-kong](https://avatars.discourse-cdn.com/v4/letter/l/96bed5/32.png) [@leonard-kong](https://forums.powershell.org/u/leonard-kong)\
**Post date:** [February 5, 2014, 5:44am UTC](https://forums.powershell.org/t/help-custom-properties-and-piping/2247/5 "2014-02-05T05:44:25Z")

</div>

Oh, I guess I should read the -full helps more often.

For the hash table, what does the “l=‘computername’” do? I’m assumed it assigned the ‘l’ variable something but turns out I was incorrect because I tried replacing it with another letter.

I’m scanning through the select-object file as we speak. Thanks again Don!

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [February 5, 2014, 6:18am UTC](https://forums.powershell.org/t/help-custom-properties-and-piping/2247/6 "2014-02-05T06:18:11Z")

</div>

“L” isn’t a variable.

Hashtables consist of one or more “key=value” pairs. In this case, two, with the keys being “L” and “E.” The Select-Object command is hardcoded to look for specific keys: L, l, n, N, name, and label all define the name of the new property it will create; e or expression defines a script block that will be run to produce the values for the new property. So “l” is short for “label.” I’ve been trying to get better about using “n” or “name” instead, because lowercase L is so easy to mistake for the number 1, but sometimes I fall into my old habit of using “l” for “label.” The command will accept either, though.

A plain old hash table can use whatever you want for keys. In this case, the hash table has to conform to what the Select-Object command is prepared to deal with.

---

<div class="post-metadata">

**Author:** ![leonard-kong](https://avatars.discourse-cdn.com/v4/letter/l/96bed5/32.png) [@leonard-kong](https://forums.powershell.org/u/leonard-kong)\
**Post date:** [February 5, 2014, 6:21am UTC](https://forums.powershell.org/t/help-custom-properties-and-piping/2247/7 "2014-02-05T06:21:43Z")

</div>

That all made perfect sense. Thanks again for the guidance, it’s helped a lot!

---

<div class="post-metadata">

**Author:** ![dmdougie](https://avatars.discourse-cdn.com/v4/letter/d/bc79bd/32.png) [@dmdougie](https://forums.powershell.org/u/dmdougie)\
**Post date:** [February 6, 2014, 1:10am UTC](https://forums.powershell.org/t/help-custom-properties-and-piping/2247/8 "2014-02-06T01:10:14Z")

</div>

Can I jump in here and suggest checking out [these videos?](http://www.microsoftvirtualacademy.com/training-courses/getting-started-with-powershell-3-0-jump-start#?fbid=7GBAm3__38E)

I watched them at the end of last year and they really helped me out. Looking forward to delving into your Powershell in a month of lunches, Don. Do you touch on AD administration at all or should I grab a copy of Jason’s book afterward?

---

<div class="post-metadata">

**Author:** ![leonard-kong](https://avatars.discourse-cdn.com/v4/letter/l/96bed5/32.png) [@leonard-kong](https://forums.powershell.org/u/leonard-kong)\
**Post date:** [February 6, 2014, 3:08am UTC](https://forums.powershell.org/t/help-custom-properties-and-piping/2247/9 "2014-02-06T03:08:35Z")

</div>

Oh, those videos look great! I’ll definitely give them a look. Thanks for the suggestion, Doug.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:52pm UTC](https://forums.powershell.org/t/help-custom-properties-and-piping/2247/10 "2024-05-16T20:52:24Z")

</div>

Closed on May 16, 2024, 8:52pm UTC


