Administrators and developers looking to take full advantage of DSC capabilities will want to investigate the available configuration resources. These resources provide the framework of what is possible natively within DSC. The power of these providers is the ability to combine multiple resources into a single configuration for a node.
PowerShell DSC is enabled on installation of WMF 4.0 with general configuration resources, as mentioned previously in this book. Since the general availability of WMF 4.0, Microsoft has released three “waves” of new resources, thus extending the native capabilities of PowerShell DSC. Be aware that many of these resources are still being improved on, so check back with Microsoft TechNet1 regularly for updates. You can get a list of available resources on your system with the Get-DSCResource cmdlet, as shown in Figure 12-7.
Figure 12-7 Get-DSCResource cmdlet
One challenge new users of PowerShell DSC will face is in understanding the properties associated with each DSC resource. Microsoft has continued the tradition of making valuable information available in the PowerShell session. There are two ways to get additional information about the resource properties. The following examples review the properties and syntax for the Script resource, as listed previously in Figure 12-7.
Using the Select-Object cmdlet, we can expand out the information about the properties:
Click here to view code image
Get-DscResource -Name Script | Select-Object -ExpandProperty Properties
Note
In this example, we take advantage of the PowerShell pipeline (|), which
permits the user to transfer object data returned from one cmdlet (Get-DscResource) to be used in the next cmdlet (Select-Object). This is a core feature that makes PowerShell so versatile.
This information, whose output is shown in Figure 12-8, tells the user the property’s
object type and whether it is required.
Figure 12-8 Select-Object cmdlet
Using the -Syntax parameter in the Get-DscResource cmdlet, you are presented with the format that you would need to use in the PowerShell configuration script, as shown in Figure 12-9:
Click here to view code image
Get-DscResource -Name Script -Syntax
Figure 12-9 Get-DscResource cmdlet –Syntax parameter
Note that you will be required to replace #ResourceName with your specified name for the resource when adding this resource into your configuration script.
Many of the new providers focus on Microsoft Hyper-V, SQL, and Active Directory.
While the first one might not be of much use to the average VMware administrator, it is likely that DevOps teams reliant on the Windows platform will be looking to implement the latter two as soon as possible.
The PowerShell community has also been hard at work producing additional resources that you can incorporate into your configurations. Most notably, you should check out the PowerShell.org GitHub2 , where you can find deeper dives into DSC and community-generated resources. Because these resources are community built, they are not supported and should be reviewed before using them, especially in production environments.
Rest assured that Microsoft is moving quickly to release new DSC providers through resource kits. With nine resource kit waves released in under a year, and with many more expected from Microsoft and other vendors, it is safe to say that your development teams will be putting PowerShell DSC to greater use as it matures. The only challenge is that the
current released resources are not always guaranteed and should be treated as is. It is easy to identify the currently unsupported resources because their names will be prefixed with an x.
Note
Microsoft states that the resource kits should be installed on Windows 8.1 and Windows Server 2012 R2. Additional requirements may apply when adding resource kits and community providers to systems running older operating systems. We have tried to provide those prerequisites in this chapter, but we suggest that you read any provided release notes before implementing and using these kits.
Summary
Microsoft has built a very flexible and desired state platform into PowerShell 4 and the Windows Management Framework 4.0. Microsoft Windows PowerShell DSC provides the capability to configure Windows systems dynamically based on configurations deployed as MOF files. This capability enables administrators, developers, and VMware
administrators to predefine the characteristics of a Microsoft Windows system and maintain its configuration over time. This is not unique in Linux environments (with the use of Puppet, Chef, and Ansible, as described in previous chapters), but it is a huge step forward for Windows environments. Development for DSC is still in its early stages, and administrators should expect greater capabilities from Microsoft in the months to come that will far exceed the current capabilities outlined in this text.
References
[1] Microsoft TechNet DSC resources: http://technet.microsoft.com/en-us/library/dn282125.aspx
[2] PowerShell.Org GitHub for DSC: http://github.com/PowerShellOrg/dsc
Chapter 13. Implementation Strategies with PowerShell DSC
VMware administrators are in a unique position in a DevOps environment because they tend to be very involved in both the operations and development side of the coin. This position requires them to be agile in how they deliver virtual machines (VMs) and virtual infrastructure to the development teams. Many VMware administrators use PowerCLI, VMware’s PowerShell snap-in, for automating tasks and reporting in their VMware
vSphere environment. This chapter discusses ways that VMware administrators may look to use PowerCLI, PowerShell 4.0, and PowerShell Desired State Configuration (DSC) to serve the needs of the entire DevOps team.
Topics covered in this chapter include the following: