Differences between System.Object type and System.Management.Automation.PSObject

Hello,

I’ve tried to find answer to my question but without luck. I’m digging into powershell types etc. and I’m trying to understand how those works in Powershell. Right now I’m checking different command types and some of commands have type like:

Command              Parameter   Type                                 
-------              ---------   ----                                 
Format-Xml           InputObject System.Management.Automation.PSObject
Get-TypeInfo         InputObject System.Management.Automation.PSObject
Get-TypeName         InputObject System.Management.Automation.PSObject
Write-ErrorString    InputObject System.Management.Automation.PSObject
Command              Parameter   Type                                 
-------              ---------   ----                                 
Update-Manifest      Value       System.Object
ConvertFrom-Metadata InputObject System.Object
Export-Configuration InputObject System.Object

Could anybody explain to me why some of commands have type System.Object and some other are PSObject? I know that PSObject is like child to System.Object and it is special kind of type for Powershell and almost everything in PS is PSObject but I see many commands that are System.Object so why not System.Management.Automation.PSObject?

What’s the difference here?

Thanks :slight_smile:

 

 

the type refers to the type of object the cmdlet returns.

to see what is actually being returned, you can call the command and pipe to get-member

Chapters 8 and 9 of the Learn windows Powershell in a month of lunches, does a really good job of giving you an overview of why object types matter, and how they come into play.

Below links will help you here

https://powershell.org/forums/topic/system-object-or-psobject/

[quote quote=176140]the type refers to the type of object the cmdlet returns.

to see what is actually being returned, you can call the command and pipe to get-member

Chapters 8 and 9 of the Learn windows Powershell in a month of lunches, does a really good job of giving you an overview of why object types matter, and how they come into play.

[/quote]

Thank you both.

But could someone clarify what PSObject is? I’ve read that it is wrapper to all objects in Powershell so just to be sure - even that object type can be system.object it is also PSObject? Am I right here? So every object in Powershell has its own type like System.IO.FileInfo but it is also PSObject but hidden from us? Am I thinking right here?