Creating PowerShell custom DSC resources in C#

You can create custom DSC resources in PowerShell using MOF schema and in PowerShell using PowerShell classes, but what if you wanted to use another language? Well, you can create DSC resources in C#, which is incidentally how most of the built-in original DSC resources were created.

Why would you create a custom DSC resource in C#? There are several reasons, some being personal preference. A C# DSC resource would have native access to the .NET framework without the intermediary PowerShell interpretation. It could also have better access to concepts such as generics or other frameworks that can't be easily used directly in PowerShell. You might also be more familiar with C# than you are with PowerShell and be more comfortable there.

In practice, the potential benefits are mostly outweighed by the time and complexity cost to make a C# custom DSC resource. As you are about to see, setting up the environment to develop this is difficult for someone who doesn't already have a C# development environment setup, and it adds extra steps to make and deploy the DSC resource. Ultimately, these trade-offs are up to you to decide.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset