An Enum type is a data type that enables a variable to be a set of predefined constants. The variable must be equal to one of the values that have been predefined for it. Enums can be more descriptive rather using just a number.

Enums are used to declare an enumeration, a distinct type that consists of a set of named constants called the enumerator list, like an example in below Animation –

Tip1

But, the Powershell Tip I learned today is that this could be used even for Parameter Validation inside a Function. To restrict the input to a list of predefined enumerations. like in below example.

tip

If you’ll try giving a Value outside the defined it will give you errors.

error

Useful – Right? 🙂

Prateek Singh

[twitter-follow screen_name=’SinghPrateik’]