When did Select-Object creates ne PSCustom Objects

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?

 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

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 ?

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
 

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

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

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.

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.

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

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