Classes and Enumerations
PowerShell 5 introduced support for creating classes and enumerations within PowerShell directly. Prior to this, classes had to be created in a language such as C#, or dynamically created using the complex dynamic assembly types in the System.Reflection
namespace.
Classes and enumerations have only changed a little in PowerShell 6 and 7. There are numerous enhancement issues open in the PowerShell project on GitHub, but they have been slow to make their way into PowerShell. Examples include support for writing interfaces and the ability to define getters and setters for properties.
This chapter explores the following topics:
- Defining an enumeration
- Creating a class
- Classes and
runspace
affinity - Transformation, validation, and completion
- Classes and DSC