Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Powershell DSC

You're reading from   Learning Powershell DSC Get started with the fundamentals of PowerShell DSC and utilize its power to automate deployment and configuration of your servers

Arrow left icon
Product type Paperback
Published in Oct 2015
Publisher
ISBN-13 9781783980703
Length 268 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
James Pogran James Pogran
Author Profile Icon James Pogran
James Pogran
Arrow right icon
View More author details
Toc

Table of Contents (9) Chapters Close

Preface 1. Introduction to PowerShell DSC FREE CHAPTER 2. DSC Architecture 3. DSC Configuration Files 4. DSC Resources 5. Pushing DSC Configurations 6. Pulling DSC Configurations 7. Example Scenarios Index

PowerShell v4 DSC

PowerShell v4 was released as part of WMF 4 on October 24, 2013, and contained the first released version of DSC. Even though this was the first release of DSC, it is still referred to as being version 4 of DSC. While confusing at first, this is largely something you can ignore, as the versioning of DSC Resources is a more frequent point of variance.

As the first release, this version of DSC largely focuses on bringing a minimally viable product to market for Microsoft. Microsoft is a little late to the DevOps game with DSC, as there are several toolsets out there that have been in use for many years. Puppet and Chef are the most notable, but there are many others. What sets DSC apart here is that it is not an add-on or separate product; it's a core part of the Windows OS and can be used by other tools as much as it can be used by itself.

The first version contains most features needed out of the gate to start automating your deployment process, but only the built in DSC Resources were available and they were lacking in addressing commonly used products such as IIS, SQL, or Exchange. In the early days, Microsoft relied heavily on the community to expand its DSC resource list, which resulted in mixed success. Microsoft released a set of DSC Resources it authored to the community in batches to address the gap. The combination of community and Microsoft contributions has greatly expanded the reach of DSC, and it has been expanding ever since.

v4 DSC language extensions

DSC adds three new functions as language extensions to support declaring the expected state of a machine:

  • Configuration: The configuration keyword is a DSC function that declares a set of operations to perform on a target system.
  • Node: The node configuration keyword is a DSC function that declares the target host to perform operations on.
  • Import-DscResource: It looks like a PowerShell Cmdlet but is really a keyword. It locates the DSC Resources needed to parse and compile the DSC configuration script.

v4 DSC base resources

The following table lists the DSC base resources of v4:

Base resource

Description

Service

The Service DSC resource performs operations against Windows services. It can start or stop a service or configure the account it runs under and the startup type of the service. This resource cannot install services; it operates only on services that are already present. See the xService resource for additional functionality.

Script

The Script resource is a versatile generic resource. It allows specifying an arbitrary block of code to be executed on the target host. There are some restrictions like variable expansion and access to some system resources. Generally, this should be used for short term or one-off situations that are not handled by an existing DSC resource, as error handling and proper idempotency is difficult to achieve in the limited space you have.

User

The User DSC resource performs operations on local users on the target system. It allows the creation or deletion of users and setting passwords and password policies, as well as the basic attributes of the user.

WindowsProcess

The WindowsProcess DSC resource performs operations on processes on the target system. This is commonly used to execute arbitrary executables with specific parameters that are not handled by an existing DSC resource.

WindowsFeature

The WindowsFeature DSC resource adds or removes features of the Windows operating system. This uses the built-in Deployment Image Servicing and Management (DISM) infrastructure of the Windows Server platform; some features are not operable using this resource on a client OS.

Registry

The Registry DSC resource adds, removes, or modifies registry entries in the target system. Support for the full range of registry keys and values is present.

Environment

The Environment DSC resource adds, removes, or modifies environment variables on the target system.

Archive

The Archive DSC resource performs operations on compressed files.

Group

The Group DSC resource performs operations on local groups on the target system. It can add, remove, or modify membership on local groups.

Package

The Package DSC resource installs software bundled in MSI or EXE formats. In the case of MSI, it can also remove software if all the necessary options are provided to the MSI command line. Please see the MSI documentation for more information about this.

Log

The Log DSC resource writes messages to the DSC operational log. This is useful for troubleshooting or diagnostic purposes.

v4 DSC Cmdlets

Cmdlet

Description

Get-DSCConfiguration

This Cmdlet returns the current DSC configuration status of the node, if the configuration exists. If it does not, this will throw an error. This can also be run on remote systems.

Get-DSCLocalConfigurationManager

This returns the current settings, or meta-configuration, of the LCM on the system, if the settings exist. This can be run on remote systems and is useful for troubleshooting DSC deployments that use DSC Pull Servers.

Get-DSCResource

This Cmdlet returns a list of all DSC Resources on the system. This is vital in troubleshooting and authoring DSC Resources, as it helps show what resources are present on the system. If the resource you are authoring is not present, then DSC cannot read the resource.

New-DSCCheckSum

This Cmdlet returns a hash from the DSC configuration MOF file. This is used to deploy MOF files to pull servers.

Remove-DSCConfigurationDocument

This Cmdlet removes the compiled MOF from the target node, along with additional cleanup tasks.

This Cmdlet is available only as part of the November 2014 update rollup for Windows RT 8.1, Windows 8.1, and Windows Server 2012 R2: http://support.microsoft.com/en-us/kb/3000850 from the Microsoft support library. Before you use this Cmdlet, review the information in What's New in Windows PowerShell: http://technet.microsoft.com/library/hh857339.aspx in the TechNet library.

Restore-DSCConfiguration

This Cmdlet restores the previous configuration for the target node, if a previous successful configuration exists on the target node.

Stop-DSCConfiguration

This Cmdlet stops a currently running configuration on a target node. This is useful in aborting interactive configuration runs initiated using Start-DSCConfiguration.

This Cmdlet is available only as part of the November 2014 update rollup for Windows RT 8.1, Windows 8.1, and Windows Server 2012 R2: http://support.microsoft.com/en-us/kb/3000850 from the Microsoft Support library. Before you use this Cmdlet, review the information in What's New in Windows PowerShell: http://technet.microsoft.com/library/hh857339.aspx in the TechNet library.

Test-DSCConfiguration

This Cmdlet runs the specified configuration against a target node, but does not execute it. It compares the current state of the system to the expected configuration, and reports back if they match. No changes are made to the system using this Cmdlet.

Set-DSCLocalConfigurationManager

This Cmdlet is used to change the settings, or meta-configuration, on the LCM on the target computer. This is most often used in Pull Server scenarios.

Start-DSCConfiguration

This Cmdlet executes the specified MOF file against the target computer. This is the Cmdlet you will use the most, as it's helpful in both authoring and troubleshooting DSC configurations and DSC Resources.

Import-DscResource

This Cmdlet is really a dynamic function that is only available at runtime. It specifies which DSC Resources need to be loaded to parse and compile the DSC configuration script.

The v4 DSC Pull Server

The DSC Pull Server is the management server that the DSC agents on target nodes pull DSC configurations and DSC Resources from. This will be explained in greater detail in Chapter 6, Pulling DSC Configurations.

You have been reading a chapter from
Learning Powershell DSC
Published in: Oct 2015
Publisher:
ISBN-13: 9781783980703
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image