This topic contains 3 replies, has 3 voices, and was last updated by
April 4, 2016 at 9:16 am #37212ParticipantPoints: 0Rank: Member
I'm currently writing a module with class-based DSC resources.
All the examples I've seen out there involve putting all the class-based DSC resources for a module in the .psm1 file, which is all fine and dandy, except that this code file gets very long after a while...
I seem to remember in the past with a preview of WMF 5 trying to put the class-based resources in their own separate ps1 files that the psm1 would load, but this did not seem to work. I have not tried again with WMF 5 RTM (yet).
Does anyone know if there is a proper / supported way to divvy up class-based DSC resources into their own files? Or for this approach is the only option to have them all inside the .psm1 file?
April 4, 2016 at 9:23 am #37214MemberPoints: 0Rank: Member
Not yet, but I believe this is intended for an upcoming update to WMF5 (possibly already there for people on the Windows 10 fast track / insider ring / whatever it's called.)
Eventually, what you'll be able to do is just list your modules in the NestedModules key of the module manifest, and you can divide up the DSC resources however you like inside the psm1 files that you put in NestedModules. There was even some documentation to that effect that leaked out by mistake, before the necessary LCM changes were actually released.
April 5, 2016 at 1:16 pm #37258ParticipantPoints: -19Rank: Member
Its all text files at the end.
You can always build yourself a small script that grabs other small scripts that will be easier to maintain for you and create the PSM file from a template you prepared in advance.
Just have to implement some checks and even pester if youre into it to make sure the PSM is in the desired "state".
April 5, 2016 at 4:36 pm #37269MemberPoints: 0Rank: Member
"Its all text files at the end.
You can always build yourself a small script that grabs other small scripts that will be easier to maintain for you and create the PSM file from a template you prepared in advance."
That's the way modules used to work, for the most part. With classes, some of this stuff happens at parse time without actually importing the module, so PowerShell and the LCM have to be able to find the classes in the expected files. It does this by looking at the files explicitly mentioned in the manifest (either the RootModule or, eventually, NestedModules.)
The topic ‘Divvying Up PowerShell Class-Based Resources in .psm1 Modules’ is closed to new replies.