0

Currently, for my modules, I store actual code in a separate file from PSM1 file, then dot source it and use Export-ModuleMember to export Functions, this way it allows me easily debug/test individual functions.

I assume it's not possible since Export-ModuleMember does not give the option to export DSCResource but is it possible to have a similar setup for class based DSC Resources?

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Gregory Suvalian
  • 3,566
  • 7
  • 37
  • 66
  • Have you exported the resources in DscResourcesToExport field? Class based resources have to be specified in this field in the module manifest - which also means it is mandatory to specify a module manifest for this module – Nana Lakshmanan May 27 '16 at 20:22
  • Yes. Apparently it's "bug" which looks like nobody reported. Per powershell.org (http://powershell.org/forums/topic/two-clsss-dsc-resources-in-one-module/) and post below – Gregory Suvalian May 27 '16 at 22:24

2 Answers2

1

Bug filed against WMF 5.0. Please upvote.

https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/14288805-nested-modules-does-not-work-invoke-dscresource

Gregory Suvalian
  • 3,566
  • 7
  • 37
  • 66
0
  1. You can have a module containing many DSC class based resources.
  2. In that module you can have 1 class per file but you can't split it further (like Test method in one file Set method in another).
  3. Powershell does not support partial classes.
N.Gupta
  • 326
  • 1
  • 5
  • Per this topic, it's not possible to have those in separate files http://powershell.org/forums/topic/two-clsss-dsc-resources-in-one-module/ – Gregory Suvalian May 25 '16 at 19:29
  • Yes you can starting WMF 5.0 RTM. Check the sample @ https://github.com/nitinbps/DSCResources/tree/master/MultiClassesNestedModulesSameDir. – N.Gupta May 25 '16 at 23:46
  • This does not work with Invoke-DSCResource though try below `Invoke-DscResource -Name nestedA -ModuleName MultiClassesNestedModulesSameDir -Method Test -Property @{path = "c:\"}` – Gregory Suvalian May 26 '16 at 20:39
  • As I started to test it more I also realized that nested module is not properly functioning in WMF 5.0 RTM – N.Gupta May 27 '16 at 17:59