Authoring DSC configuration files

In previous chapters, we stated that you can author configuration files in any text editor you want and how important that is for both cross-platform use and tooling choice freedom. In practice, your choice of text editor largely depends on your preferences and the interactive experience you want as you type. The best thing about authoring files for DSC is that you can pick and choose whichever text editor you want to use at any point in time in your workflow. You don't have to stick with one or the other as you progress in your use of DSC.

When you are first starting out with DSC, or really any new technology, you will benefit from tools that provide you with immediate feedback on whether you are correct or not in the code you are writing. These features are the key to your first forays into authoring configuration files as they provide immediate usefulness without having to look back at the documentation outside the editor. This is invaluable as a first line of defense against bugs and common errors when first starting out, and we will explore more of this in the last section of this chapter as debugging DSC on target nodes is an involved process and not always easy.

Historically, the PowerShell ISE provided you with the best learning experience as it was the only editor available that provided that immediate feedback. It has syntax highlighting for DSC language features and cmdlets as well as for other PowerShell language features. The ISE IntelliSense autocompletes all DSC cmdlets and language features and additionally provides inline help tooltips for DSC resource parameter sets. The ISE parser will automatically evaluate your script in real time for syntax errors and missing parameters.

Since the first edition of this book, Visual Studio Code has been released and reached version 1 status. It has rapidly become the default editor of choice for many scripters regardless of the language. The extension model allows many useful extensions to be added, one of which is the PowerShell extension from the PowerShell team. This extension lights up the same syntax highlighting and IntelliSense features as the ISE but releases at a much faster rate than the ISE can. This means bugs are addressed more quickly, and new features come out more frequently than the ISE can as it's tied to the OS release model.

Since we are writing text files, the list of third-party editors is huge and potentially includes anything out there. We are going to mention one in particular here, as its features merit mention all by themselves. Sublime Text has advanced textual editing that includes multiple selections, configurable keyboard shortcuts, powerful file and function search and replacement, and a command pallet that allows execution of any feature of Sublime Text without the menu navigation. For a better explanation and more examples, go to its website and try it out.

What do I use? Most of the time, use Sublime Text and fall back on PowerShell ISE if things go wrong.

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

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