# What is the difference between psCustomObject and PSObject?

**URL:** https://forums.powershell.org/t/what-is-the-difference-between-pscustomobject-and-psobject/3887
**Category:** PowerShell Help
**Created:** [March 16, 2015, 1:42am UTC](https://forums.powershell.org/t/what-is-the-difference-between-pscustomobject-and-psobject/3887 "2015-03-16T01:42:53Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![gregory-suvalian](https://avatars.discourse-cdn.com/v4/letter/g/9d8465/32.png) [@gregory-suvalian](https://forums.powershell.org/u/gregory-suvalian)
#### Post date: [March 16, 2015, 1:42am UTC](https://forums.powershell.org/t/what-is-the-difference-between-pscustomobject-and-psobject/3887/1 "2015-03-16T01:42:53Z")

</div>

I’m using PowerGUI script editor and it insists on replacing references of [psCustomObject] with full notation of [Management.Automation.PSObject] which surprisingly produces completely different output during output to pipeline

```
PS C:\WINDOWS\system32> [pscustomobject].GetHashCode() -eq [Management.Automation.PSObject].GetHashCode()
True
PS C:\WINDOWS\system32> [Management.Automation.PSObject]@{A="1"; B= "2"; C= "3"}

Name Value
---- -----
C 3
B 2
A 1

PS C:\WINDOWS\system32> [PSCustomObject]@{A="1"; B= "2"; C= "3"}

A B C
- - -
1 2 3
```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)
#### Post date: [March 16, 2015, 1:46am UTC](https://forums.powershell.org/t/what-is-the-difference-between-pscustomobject-and-psobject/3887/2 "2015-03-16T01:46:16Z")

</div>

[pscustomobject] triggers some special behavior in the PowerShell parser (in v3 and later). It has to be done that way, rather than treating it as a normal type literal and casting a hashtable, because hashtables immediately lose the order that their keys were added. (This behavior was added at the same time as the [ordered] @{ } syntax.)

---

<div class="post-metadata">

### Author: ![gregory-suvalian](https://avatars.discourse-cdn.com/v4/letter/g/9d8465/32.png) [@gregory-suvalian](https://forums.powershell.org/u/gregory-suvalian)
#### Post date: [March 16, 2015, 1:47am UTC](https://forums.powershell.org/t/what-is-the-difference-between-pscustomobject-and-psobject/3887/3 "2015-03-16T01:47:13Z")

</div>

OK, will raise it as bug with PowerGUI team. Thanks.

---

<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: [March 16, 2015, 1:49am UTC](https://forums.powershell.org/t/what-is-the-difference-between-pscustomobject-and-psobject/3887/4 "2015-03-16T01:49:23Z")

</div>

[PSCustomObject] is a type accelerator. It constructs a PSObject, but does so in a way that results in hash table keys becoming properties. PSCustomObject isn’t an object type per se - it’s a process shortcut. The docs are relatively clear about it ([https://msdn.microsoft.com/en-us/library/system.management.automation.pscustomobject(v=vs.85).aspx](https://msdn.microsoft.com/en-us/library/system.management.automation.pscustomobject(v=vs.85).aspx)) - PSCustomObject is a placeholder that’s used when PSObject is called with no constructor parameters.

So you’re not really creating two different things in your examples - you’re creating one thing, using two different processes. When you create just a PSObject, and assign a hash table to it, you’re really just producing a hash table. There’s no interpretation process, as there is when you use the type accelerator instead.

---

<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:45pm UTC](https://forums.powershell.org/t/what-is-the-difference-between-pscustomobject-and-psobject/3887/5 "2024-05-16T20:45:36Z")

</div>


