Chapter 19. Classes in PowerShell
This chapter covers
- The basic ideas underlying classes in PowerShell
- PowerShell class and enumeration creation
- Detailed discussion of properties and methods in PowerShell classes
- Method overloading and inheritance
- Class initialization and construction
- DSC resources based on PowerShell classes
Oh brave new world that has such people in it!
Miranda in William Shakespeare’s The Tempest
PowerShell has always been a .NET language in that it worked with and consumed the types in the .NET framework, but it was always a kind of second-class citizen compared to other .NET languages because you couldn’t create new types directly in PowerShell. This has been fixed in PowerShell v5, which now supports the ability to define new classes as well as extend existing .NET classes.
Note
In this chapter, we’re going to look at what defining classes allows you to do as a PowerShell scripter/programmer. Also, one of the primary drivers for introducing classes in v5 was to make it easier to define DSC management resources. In the latter part of the chapter, we’ll look at how this is done.