Troubleshooting Modules/Resources

So I wrote myself a cool module that works fantastically in my lab and I decided to pocket it to use for client to help hydrate some new installations and speed things up only to have it completely error out and not work.

Well that’s no fun. Thankfully my modules are rather rich in verbosity so I even know where they failed but the thing I don’t get is … why. Running them manually works perfectly. using psexec to launch powershell in the system context even works perfectly (I assume it runs under the system context)… yet when I start-dscconfiguration and “make it so” it fails gloriously. So obviously my modules are not accounting for something … but I have no idea what (again they work in my lab … so there’s something unique to the client servers and I’d rather figure it out so the module gets more robust).

So how do you guys troubleshoot things when they simply don’t work? Is there some kind of tool that can be run to look at the running process directly and try to figure out what it can and can’t see? Is there a command that can be used to execute code in the same context of DSC (if it’s not in the system context?) with -verbose and well placed entries I know exactly what line my code is failing at … but I can’t figure out why as it runs perfect in the system and current user contexts…

DSC runs as LocalSystem. Beyond that, you’re doing everything right; enable the Analytic and Debug logs to see your Write-Verbose and Write-Debug output.

At this point, general questions are out the window, and we’d need to see what you’ve already figured out: what statements are not behaving the way you think they should, and what are the actual results? Error messages? etc.

Well in this case the culprit ended up being my old nemesis: GPOs and Execution Policy. It happened to be set so tight even some Microsoft modules refused to import which in turn made some of my modules run incorrectly.

The question was more inline with “so how do you guys troubleshoot” like if there was some buried log file somewhere I didn’t know about :slight_smile: Thanks for confirming I’m going in the right direction.