Installing required DSC resources

Whether you are compiling your DSC configuration to an MOF file on your desktop or on the DSC pull server itself, you need to have the xPSDesiredStateConfiguration module that contains the xDscWebService DSC resource in $env:PSModulePath.

You can use the built-in PackageManagement module to download xPSDesiredStateConfiguration, clone xPSDesiredStateConfiguration directly from https://github.com/PowerShell/xPSDesiredStateConfiguration using Git, or download it in a ZIP file from the GitHub website:

For more information on the sources of DSC resources, refer to Chapter 4, DSC Resources.

To use the built-in PackageManagement cmdlets to download and install the DSC resource to the correct place automatically (note the backticks that allow the multi-line command), take a look at this:

Install-Package -Name 'xPSDesiredStateConfiguration' `
-RequiredVersion 6.4.0.0 `
-Force

Note that we specified the version in the code example. We did this to show what version we were working with when the book was written so that you know which version to use when running examples. You may use a newer version in production than the one specified here, as it is bound to change as time moves on.

In our downloadable example code, we also download and install the xWebAdministration DSC resource as we use this in our example DSC configuration that we will be pushing to the target nodes (note the backticks that allow the multi-line command):

Install-Package -Name 'xWebAdministration' `
-RequiredVersion 1.18.0.0 `
-Force

If you are going to use the SMB DSC pull server, then you must also download the xSmbShare DSC resource in order to automatically create SMB shares:

Install-Package -Name 'xSmbShare' `
-RequiredVersion 2.0.0.0 `
-Force

In the first edition of this book, we went through a lot of hoops in order to package the DSC resources we want the DSC pull server to deploy for us. Fortunately, in the time that has elapsed, the tooling has caught up and we no longer need the custom PowerShell scripts the author wrote to do this. We can now use the DSCPullServerSetup module provided in the xPSDesiredStateConfiguration DSC resource repository: https://github.com/PowerShell/xPSDesiredStateConfiguration/tree/dev/DSCPullServerSetup.  As we're about to see later on, we can point the new tooling at the folder we downloaded the DSC Resources to using PackageManagement (Install-Module), and it will discover and package the correct folders for us. 

The reason this is a welcome change is that the folder structure downloaded by Install-Module supports the side-by-side installation mechanics in WMF 5, which means it contains a subfolder named with the version number: 

[PS]> ls $env:ProgramFilesWindowsPowerShellModulesxWebAdministration

Directory: C:Program FilesWindowsPowerShellModulesxWebAdministration

Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 9/17/2015 1:49 PM 1.18.0.0

[PS]> ls $env:ProgramFilesWindowsPowerShellModulesxWebAdministration1.18.0.0

Directory: C:Program FilesWindowsPowerShellModulesxWebAdministration1.18.0.0

Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 9/17/2015 1:49 PM DSCResources
-a---- 9/17/2015 1:49 PM 1473 xWebAdministration.psd1

The DSC pull server doesn't recognize that format and so we would have had to manually account for that if not for the new tooling. Thanks to the Publish-DSCModuleAndMof function in the DSCPullServerSetup module, we can skip packaging the DSC resources now and put it as part of our deployment process later on in this chapter when we compile and deploy the MOFs to the DSC pull server. This simplifies your steps and makes things altogether easier and we'll get to that soon; first, however, there is one more pre-installation step to explain.

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

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