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

Welcome Forums General PowerShell Q&A Differences between System.Object type and System.Management.Automation.PSObject

Viewing 3 reply threads
  • Author
    Posts
    • #176035
      Participant
      Topics: 1
      Replies: 1
      Points: 18
      Rank: Member

      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 🙂

       

       

    • #176140
      Participant
      Topics: 23
      Replies: 160
      Points: 438
      Helping Hand
      Rank: Contributor

      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.

    • #176164
      Senior Moderator
      Topics: 8
      Replies: 1140
      Points: 3,921
      Helping Hand
      Rank: Community Hero
    • #176356
      Participant
      Topics: 1
      Replies: 1
      Points: 18
      Rank: Member

      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.

      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?

Viewing 3 reply threads
  • You must be logged in to reply to this topic.