PowerShell Module: Creating PowerShell Module with Class and Objects vs Function

I am on my way to create a custom powershell module for one of our recovery products. Currently it is been developed with the help of powershell functions. I am thinking of experimenting the same with the help of PowerShell class and object constructs, but i am not sure if i should do it all or not.

Please help me to understand following-

  1. Should we create PowerShell module with the help of Class and Object?
  2. If Yes, Than Why?
  3. what are the benefits of having Class and Objects compare to PowerShell functions?
  4. Does it help us in creating custom Object types efficiently and manage the objects in effective way?
  5. if not, then what are the drawbacks of having module written as Class and object compare to Function.


Hi there,

Please see my comments below…

  1. It is not mandatory to write PowerShell classes to create the modules, it is completely up to you. But PowerShell modules will not export the classes, you need to create an object for that class in the module itself and export it using functions.
  2. -
  3. You can create custom type objects with your own members (Properties, Methods & etc.,)
  4. Yes
  5. -
Thank you.