Chapter 27. Custom type extensions
This chapter covers
- Using PowerShell’s Extensible Type System
- Creating custom type extensions
- Importing custom type extensions
- Creating custom type extensions dynamically
Windows PowerShell includes a feature known as the Extensible Type System (ETS). A type, in PowerShell’s world, is a data structure that describes what a type of data looks like, as well as what capabilities that type of data has. For example, there’s a type that represents a Windows service. The type says that a service has a name, a description, a status, and other properties. The type also says that a service has methods enabling you to stop the service, start it, pause it, resume it, and so on.
Types are generally born within the .NET Framework that lies underneath PowerShell.
Warning
The objects returned by PowerShell aren’t necessarily pure .NET objects. In many cases the PowerShell wrapper will add, or hide, properties and methods. Use the options on the –View parameter of Get-Member to determine the modifications that have been performed.
So, the properties and methods—collectively, the members—of a type are defined in the Framework and carried up through PowerShell to you. You can visit http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicecontroller.aspx to see Microsoft’s .NET Framework documentation for a service, and you’ll see its properties, methods, and so on.