Today’s Friday Fun isn’t exactly groundbreaking but you might find it useful in your PowerShell script development process. You might even learn a little something about the PowerShell ISE which is really the point of these articles anyway. How many times have you been working on a script or PowerShell tool and know that you’ll have to write some section of code but aren’t ready to tackle it now? Hopefully you are at least savvy enough to insert a comment reminding you what you need to do. So why not make this simple step as easy as possible in the PowerShell ISE?
A few days ago I posted a PowerShell script that would generate a DSC configuration template. The idea was to generate all the code you might need and let you whittle it down to just what you need. On my primary system, I don’t have any community or experimental DSC resources so my configuration template script only gets the default resources. Towards the end of the article I mentioned that another option would be to create snippets you could use in the PowerShell ISE. So I did.
In PowerShell 4 Microsoft already includes a simple DSC configuration snippet. In the ISE, hit Ctrl+J and start typing DSC and you should see a snippet title DSC Configuration (simple). I ran my configuration template script and then converted each resource into its own snippet just for you.
Download DSC-Resource-Snippets.zip and extract the .ps1xml files to your Snippets directory, C:\Users\
Find the one you want and press Enter. Use these snippets in conjunction with the DSC configuration snippet and you are practically finished with just a few key strokes. Edit and enjoy.