PowerShell 5 introduced support for creating classes and enumerations within PowerShell directly. Prior to this, classes had to be imported from an assembly written in a language such as C#, or dynamically created using the dynamic module builders.
Classes and enumerations are undergoing a great deal of change in PowerShell Core. There are numerous enhancement issues open in the PowerShell project on GitHub that are slowly making their way into PowerShell Core. Examples include the addition of interfaces, support for using validation attributes on properties, and the ability to override getters and setters for properties.
This chapter will explore the following topics:
- Defining an enumeration
- Creating a class
- Argument transformation attribute classes
- Validation attribute classes
- Classes and DSC