ClassesÂ
With version 5, classes have been introduced to PowerShell. If you are coming from a developer background, you may already be familiar with classes. A class is a data structure for storing properties and methods. Classes in PowerShell, though, have some limitations and are very rarely used. The most common use case is their implementation for the Desired State Configuration, which we will dive into in a later chapter. Therefore, we will give you only a short introduction to classes, and provide further links and material that you can have a look at.
The creation of a simple class starts with the class
 keyword. The class description is like a model. Think of it as a recipe for a fantastic PowerShell cake. It can be used to create hundreds of cakes.
You should always add a constructor to the class. A constructor is the first code that will be executed, and is always named the same as the class itself.
The first example is very straightforward:
#Class with constructor
class FantasticPowerShellCake...