This topic contains 3 replies, has 2 voices, and was last updated by
October 21, 2016 at 10:15 pm #55757
Can you please suggest an optimal way to share common functions among multiple DSC resources?
For instance, I have a logging helper function called "Write-Log" which I need to use from multiple custom DSC resources. So instead of duplicating these kind of logic pieces in multiple places, can I store them in a central place and consume them without repeating myself?
Thanks for your help!
October 22, 2016 at 1:00 pm #55777
Figured out. Never mind. Thanks!
October 22, 2016 at 9:03 pm #55792
I'm bit confused about the static and dynamic variables used in DSC configurations.
I am using private helper functions in my DSC resources. Those are being executed ahead of the time which in my opinion is weird.
For instance in my configuration file i have 2 dsc resources let's say R1 and R2. R2 depends on R1. One of the R2 dsc properties is 'LogMessage' which uses a private function to pull its value instead of a static string. The private function reads a file generated by R1 lets say file1.txt and returns the message string. My script fails stating that the file1.txt doesn't exist. If I remove R2 from the configuration script, it works and file1.txt gets generated.
What am I missing here?
October 28, 2016 at 8:11 am #56342ParticipantTopics: 5Replies: 261Points: -19Rank: Member
When you're saying "R2 depends on R1", is that just your logic or did you actually use the DependsOn property ?
The topic ‘Common helper functions across DSC resources’ is closed to new replies.