PowerShell Desired State Configuration (DSC) Resources are an evolved type of function usually created by experienced PowerShell coders. Resources are at the very core of DSC and contain the code required to perform the actual configuration tasks in your deployments.
In my previous post, I used a DSC Resource called File and executed it a number of ways to manipulate a text file. You can view its syntax in the console by using the Get-DSCResource cmdlet with the -Syntax switch.
Built in Resources
DSC comes with a small number of built-in Resources for configuring files and folders, roles and features, security groups, registry settings, environment variables, and services and processes. You can view these built in resources by typing Get-DSCResource. This screenshot of my laptop, this is an example of what you would see with the default setup.
You can find more information on these build-in resources here: Built-In Windows PowerShell Desired State Configuration Resources
Powershell Team Resources
From December 2013 to February 2015 the PowerShell team released a number of DSC Resources called the DSC Resource Kit. These contained a number of PowerShell modules that contained DSC resources and example configurations. They were published to Technet in the PowerShell gallery.
These were great resources but were by no means complete. They were starter modules intended as guidance and working examples to help the community develop their own resources.
Sadly the PowerShell team have stopped publishing the resource kit at wave 10. They are however, still releasing new and updated resources via the PowerShell Gallery and recommend that you use PowerShellGet (in WMF 5.0) to find them.
These resources are offered freely but without any support. If you find any issues etc you can post a request on Microsoft Connect but don’t hold your breath. I posted a request last September that has had no response. Bugs however are answered slightly quicker like this one. DSC: xIPAddress IP detection issue I’ve still not seen a fix though. In the end I just fixed the bug myself and renamed the resource to a comunity resource using the standards Microsoft suggest at the bottom of this page.
Speaking of which, you can develop your own resources or download them from the community. I’ll be releasing my own resources shortly in a kit to help automate the building of the Windows Server 2012 R2 Test Lab Guide.
Microsoft suggest prefixing your own resources with ‘c’ for community. If you do build your own resource then the PowerShell Team have posted the really helpful PowerShell DSC Resource Design and Testing Checklist on their blog. Thanks guys!
Corporate or private resourses.
You could create your own internal corporate standard. Eg. ‘e’ for enterprise. This would help to indicate that these are private and should not leave your business environment. But then again, that’s your own business.
Installing resources from the internet.
The first thing to do is (after a virus/malware scan) right-click and unblock the archive before accessing it as it came from the internet. If not then the contents will also be still blocked and you’ll have fun unblocking each of the files in turn.
As always never put code from the internet into your production environments. Use the online resources as examples to help develop your own code.
Unpack the contents into the folder C:\Program Files\WindowsPowerShell\Modules\
Then use Get-DSCResource to see if you can now access them. If you can still only see the built in resources then it’s likely that you will need to download and install Hotfix KB 2883200 (Windows 8.1 and Windows Server 2012 R2 General Availability Update Rollup)
This is the last of the basic topics that I’ll be posting on DSC. Next I’ll share the resources that have helped me learn DSC and then I’ll post details of the hurdles and gotcha’s I came across when trying to build my own resource.