# When did Select-Object creates ne PSCustom Objects

**URL:** <https://forums.powershell.org/t/when-did-select-object-creates-ne-pscustom-objects/51>\
**Category:** PowerShell Help\
**Created:** [May 13, 2013, 9:43pm UTC](https://forums.powershell.org/t/when-did-select-object-creates-ne-pscustom-objects/51 "2013-05-13T21:43:06Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![peter-kriegel](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/peter-kriegel/32/326_2.png) [@peter-kriegel](https://forums.powershell.org/u/peter-kriegel)\
**Post date:** [May 13, 2013, 9:43pm UTC](https://forums.powershell.org/t/when-did-select-object-creates-ne-pscustom-objects/51/1 "2013-05-13T21:43:06Z")

</div>

Howdy!

I thougt every time I strip down some Properties from an object, Select-Object will create a new PSCustom Object!  
But this lines ar not new PSCustom Objects!  
\<code\>Get-Item C:\Windows\explorer.exe | Select-Object Fullname,length  
Get-Item C:\Windows\explorer.exe | Select-Object Fullname,@{Name=“Size”;Expression={$\_.length / 1mb}} \</code\>  
Is there any rule when Select-Object is creating new PSCustom Objects from an given Object?

---

<div class="post-metadata">

**Author:** ![artb0514](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@artb0514](https://forums.powershell.org/u/artb0514)\
**Post date:** [May 13, 2013, 11:55pm UTC](https://forums.powershell.org/t/when-did-select-object-creates-ne-pscustom-objects/51/2 "2013-05-13T23:55:25Z")

</div>

Â Save the Get-Item call into a variable and you will see that it reallyÂ is a PSCustomObject.

```
$File = Get-Item C:\Windows\explorer.exe | Select-Object Fullname,@{Name=â€Sizeâ€;Expression={$_.length / 1mb}} 
$File.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False PSCustomObject System.Object
```

---

<div class="post-metadata">

**Author:** ![peter-kriegel](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/peter-kriegel/32/326_2.png) [@peter-kriegel](https://forums.powershell.org/u/peter-kriegel)\
**Post date:** [May 14, 2013, 12:56am UTC](https://forums.powershell.org/t/when-did-select-object-creates-ne-pscustom-objects/51/3 "2013-05-14T00:56:04Z")

</div>

Hi Art !

Thank you for pointing me to that!  
Even i have missed that Get-Member is reportingÂ **Selected**.System.IO.FileInfo  
But…

Is there a rule orÂ explanation when Select-Object is creating new Objects and when not ?

---

<div class="post-metadata">

**Author:** ![artb0514](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@artb0514](https://forums.powershell.org/u/artb0514)\
**Post date:** [May 14, 2013, 1:50am UTC](https://forums.powershell.org/t/when-did-select-object-creates-ne-pscustom-objects/51/4 "2013-05-14T01:50:13Z")

</div>

According to _Get-Help Select-Object -Full_, the cmdlet output is always:

> Outputs

> The output type is the type of the objects that the cmdlet emits.
> - **System.Management.Automation.PSObject**

&nbsp;

---

<div class="post-metadata">

**Author:** ![peter-kriegel](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/peter-kriegel/32/326_2.png) [@peter-kriegel](https://forums.powershell.org/u/peter-kriegel)\
**Post date:** [May 14, 2013, 3:03am UTC](https://forums.powershell.org/t/when-did-select-object-creates-ne-pscustom-objects/51/5 "2013-05-14T03:03:16Z")

</div>

The documentation is not correct !  
If you use the -First -last and -Unique Parmeters the Objects are left original.  
I think the rule is:

Whenever you strip down Properties an PScustom Object is generated!?

---

<div class="post-metadata">

**Author:** ![artb0514](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@artb0514](https://forums.powershell.org/u/artb0514)\
**Post date:** [May 14, 2013, 3:27am UTC](https://forums.powershell.org/t/when-did-select-object-creates-ne-pscustom-objects/51/6 "2013-05-14T03:27:10Z")

</div>

OK. It looks like you get a PSCustomObject if you specify a Property name (without -ExpandProperty, of course); otherwise it looks like the orginal object is passed through.

Examples:

(Get-QADGroup -SizeLimitÂ 2 | Select -First 1).GetType() returns ArsGroupObject

but

(Get-QADGroup -SizeLimitÂ 2 | Select DN -First 1).GetType returns PSCustomObject

---

<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:** [May 14, 2013, 11:21am UTC](https://forums.powershell.org/t/when-did-select-object-creates-ne-pscustom-objects/51/7 "2013-05-14T11:21:46Z")

</div>

v2 produced a PSCustomObject. v3 produces a Selected.x.x.x object. That’s in part so that the formatting system can still differentiate and provide some default formatting views, and so that the ETS can provide some type extensions. It’s technically still a PSCustomObject underneath.

But, overall, what you’re dealing with is a concept call immutability. For example, a System.Diagnostics.Process ALWAYS has certain properties. Take one away, and it’s no longer that object, by definition. It’s like if you have a car, and I chopped off the front part. It’s no longer a car, it’s a wreck. So when you select anything other than -Property \*, what Select-Object produces isn’t the original object anymore, and so you see the TypeName change.

---

<div class="post-metadata">

**Author:** ![mjolinor](https://avatars.discourse-cdn.com/v4/letter/m/d2c977/32.png) [@mjolinor](https://forums.powershell.org/u/mjolinor)\
**Post date:** [May 14, 2013, 12:37pm UTC](https://forums.powershell.org/t/when-did-select-object-creates-ne-pscustom-objects/51/8 "2013-05-14T12:37:57Z")

</div>

**So when you select anything other than -Property \*, what Select-Object produces isnâ€™t the original object anymore, and so you see the TypeName change.**

Actually -Property \* will get you a custom object too. It looks like the original object, but all the methods are gone.

---

<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:** [May 14, 2013, 12:49pm UTC](https://forums.powershell.org/t/when-did-select-object-creates-ne-pscustom-objects/51/9 "2013-05-14T12:49:29Z")

</div>

Yeah, true dat. Anything other than the original ain’t the original anymore ;). Like Levi’s.

---

<div class="post-metadata">

**Author:** ![peter-kriegel](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/peter-kriegel/32/326_2.png) [@peter-kriegel](https://forums.powershell.org/u/peter-kriegel)\
**Post date:** [May 15, 2013, 3:37am UTC](https://forums.powershell.org/t/when-did-select-object-creates-ne-pscustom-objects/51/10 "2013-05-15T03:37:50Z")

</div>

So I like to say a big THANKS to you all for clarification. (Especially Don)  
Very hard stuff!

---

<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:57pm UTC](https://forums.powershell.org/t/when-did-select-object-creates-ne-pscustom-objects/51/11 "2024-05-16T20:57:48Z")

</div>

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


