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:

      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: 25
      Replies: 184
      Points: 657
      Helping Hand
      Rank: Major 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: 9
      Replies: 1309
      Points: 4,781
      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
  • The topic ‘Differences between System.Object type and System.Management.Automation.PSObject’ is closed to new replies.