I am working on a DSC resource (cChoco) that currently depends on an outside utility (choco list
) to gather the information needed to Test-TargetResource. My problem is that the utility I have to call is very slow, and because cChoco installs many programs it currently has to pull the full list of installed software for each instance in the DSC MOF file.
The only way I have been able to come up with to work around this issue, is to pull the list of installed applications and write it to disk, and then just read it back from the file for subsequent runs, however this feels like a bit of a kluge to me. Are there any generally accepted design patterns for passing state between DSC resources or instances of the same resource other than just writing to a file? It seems like the limitations imposed on PowerShell by the DSC/Mof implementation requires a functional approach to designing resources so maybe if there are no generally accepted "right" ways to accomplish this in DSC, there would be something I could borrow from a more functional programing language?
If more background would be helpful check out https://github.com/chocolatey/cChoco/issues/90.
Data sharing between resources (and instances of the same resource) is not possible in DSC. This is an open ask: https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/13399734-returning-information-from-dsc-resource-to-another