12.1. Modifying Objects and Types

As we already discussed in Chapter 1, a PowerShell object is a complex animal. Whenever you get an object instance, you do not really manipulate the original object no matter where it is coming from: .NET, COM, WMI, or elsewhere. All objects in PowerShell are really instances of the PSObject type or its inheritors. The PSObject type is the basis—the foundation of the extended type system. It is implemented as an object wrapper, and it holds a reference to the real object. The operations that we perform on the real object all go through the PSObject instance, where they can be intercepted and manipulated by the type system. This allows for exposing functionality by adding properties and methods that are not present ...

Get Pro Windows PowerShell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.