Surprisingly, [pscustomobject] is the same as [psobject]: both these type accelerators point to type [System.Management.Automation.PSObject], even though there is a distinct [System.Management.Automation.PSCustomObject] type.
Mostly, this conflation goes unnoticed (and has come up before - see #2295), but:
# Even though their names strongly suggest identity, they are different types.
> [pscustomobject] -eq [System.Management.Automation.PSCustomObject]
False
# Any object returned by a *command* (as opposed to an expression)
# returns $True for -is [psobject], and therefore also [pscustomobject]
> (Get-Item /) -is [pscustomobject]
True
# Casting anything other than a hashtable literal to [psobject] is a no-op,
# and therefore also with [pscustomobject]
> ([pscustomobject] 666).GetType().Name
Int32
Environment data
PowerShell Core v6.0.0-beta.4
Surprisingly,
[pscustomobject]is the same as[psobject]: both these type accelerators point to type[System.Management.Automation.PSObject], even though there is a distinct[System.Management.Automation.PSCustomObject]type.Mostly, this conflation goes unnoticed (and has come up before - see #2295), but:
what is the rationale for it?
it makes for surprising behavior on occasion - see below.
Environment data