Creating Classes and Objects in PowerShell

With release of PowerShell 5 in Server 2016 and Windows 10 adding custom classes has been made simpler with the new Class functionality, however, for those of us working on older versions we need to resort to the old way of embedding C#.

For the sake of keeping examples simple, let’s say we want to create a class that holds some basic user details such as name and email address, the following would be used. In many circumstances a custom class may not be needed, and objects can be created using the New-Object cmdlet. See the below example which creates an object to hold DHCP Scope data.


If you enjoyed this post consider sharing it on , , , or , and .