PSObject Class
TOC
Collapse the table of content
Expand the table of content

PSObject Class

 

Updated: April 27, 2016

Applies To: Windows PowerShell

Encapsulates a base object of type Object or type PSCustomObject to allow for a consistent view of any object within the Windows PowerShell environment.

Namespace:   System.Management.Automation
Assembly:  System.Management.Automation (in System.Management.Automation.dll)

System.Object
  System.Management.Automation.PSObject

[SerializableAttribute]
public class PSObject : IFormattable, IComparable, ISerializable, 
	IDynamicMetaObjectProvider

NameDescription
System_CAPS_pubmethodPSObject()

Initializes a new instance of the PSObject class that contains a base object of type PSCustomObject.

System_CAPS_pubmethodPSObject(Object)

Initializes a new instance of the PSObject class that contains a base object of type Object.

System_CAPS_protmethodPSObject(SerializationInfo, StreamingContext)

Initializes a new instance of the PSObject class with serialization information. Introduced in Windows PowerShell 3.0.

NameDescription
System_CAPS_pubpropertyBaseObject

Gets the base object of the PSObject object. If the base object is another PSObject object, then its base object is returned.

System_CAPS_pubpropertyImmediateBaseObject

Gets the encapsulated base object. If the base object is another PSObject object, then its base object is returned.

System_CAPS_pubpropertyMembers

Gets all members of this PSObject object. This includes the members of the base object, extended members, and the native members defined by the PSObject class.

System_CAPS_pubpropertyMethods

Gets the methods contained in the PSObject object. This includes the methods of the base object and any extended methods.

System_CAPS_pubpropertyProperties

Gets the properties of the PSObject object. This includes the properties of the base object and any extended properties.

System_CAPS_pubpropertyTypeNames

Gets the type names of the PSObject object.

NameDescription
System_CAPS_pubmethodSystem_CAPS_staticAsPSObject(Object)

Initializes a new instance of the PSObject class based on a supplied object.

System_CAPS_pubmethodCompareTo(Object)

Compares the base object to a specified object.

System_CAPS_pubmethodCopy()

Makes a copy of the current PSObject object.

System_CAPS_pubmethodEquals(Object)

Compares the base object to a specified object to see if they are equal.(Overrides Object.Equals(Object).)

System_CAPS_protmethodFinalize()

(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Retrieves a hash code for a particular type.(Overrides Object.GetHashCode().)

System_CAPS_pubmethodGetObjectData(SerializationInfo, StreamingContext)

Populates an object with the data needed to serialize the PSObject. Introduced in Windows PowerShell 3.0.

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethodToString()

Converts the base object to a string.(Overrides Object.ToString().)

System_CAPS_pubmethodToString(String, IFormatProvider)

Converts the base object to a string by using a specified format provider.

NameDescription
System_CAPS_pubfieldSystem_CAPS_staticAdaptedMemberSetName

Specifies the name of the adapted member set. This field is constant.

System_CAPS_pubfieldSystem_CAPS_staticBaseObjectMemberSetName

Specifies the name of the base object member set. These are the members of the encapsulated base object. This field is constant.

System_CAPS_pubfieldSystem_CAPS_staticExtendedMemberSetName

Specifies the name of the extended member set. These are the members added to the PSObject object. This field is constant.

NameDescription
System_CAPS_puboperatorSystem_CAPS_staticImplicit(Boolean to PSObject)

Converts a Boolean to a PSObject. Introduced in Windows PowerShell 3.0.

System_CAPS_puboperatorSystem_CAPS_staticImplicit(Double to PSObject)

Converts a Double to a PSObject. Introduced in Windows PowerShell 3.0.

System_CAPS_puboperatorSystem_CAPS_staticImplicit(Hashtable to PSObject)

Converts a Hashtable to a PSObject. Introduced in Windows PowerShell 3.0.

System_CAPS_puboperatorSystem_CAPS_staticImplicit(Int32 to PSObject)

Converts an Int32 to a PSObject. Introduced in Windows PowerShell 3.0.

System_CAPS_puboperatorSystem_CAPS_staticImplicit(String to PSObject)

Converts a String to a PSObject. Introduced in Windows PowerShell 3.0.

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodIDynamicMetaObjectProvider.GetMetaObject(Expression)

Retrieves the dynamic metaobject that is responsible for binding operations performed on this PSObject. Introduced in Windows PowerShell 3.0.

The PSObject object is the basis for access to all objects from the scripting language and provides an abstraction for the cmdlet developer. Specifically, by deriving from this class, all PSObjects can be serialized (with ISerializable), formatted into a string (by IFormatable), use comparison operators (with IComparable), and dynamically bound (with IDynamicMetaObjectProvider).

It is permitted to derive from this class, but there is no established scenario for doing this.

namespace HostPS1e
{
    class HostPS1e
    {
        static void Main(string[] args)
        {
            // Using the PowerShell.Create and AddCommand 
            // methods, create a command pipeline.
            PowerShell ps = PowerShell.Create().AddCommand("Sort-Object");

            // Using the PowerShell.Invoke method, run the command
            // pipeline using the supplied input.
            foreach (PSObject result in ps.Invoke(new int[] { 3, 1, 6, 2, 5, 4 }))
            {
                Console.WriteLine("{0}", result);
            } // End foreach.
            Console.ReadLine();
        } // End Main.
    } // End HostPS1e.
}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft