Use the updated PsDscResources instead of built-in DSC resources in Windows Server 2016

Powershell Logo

Powershell Logo

Microsoft has issued a statement that in order to keep updating the built-in PSDesiredStateConfiguration Resources that ship in the box with Windows 10 or Windows Server 2016, you should now use the PSDscResources module (located in the PowerShell gallery)instead of the old PSDesiredStateConfiguration, which can be downloaded and installed with Find-Module PsDscResources| Install-Module PsDscResources. This module currently contains an updated Service DSC Resource, which is a very useful resource to use. The reason that I like to use the Service Dsc Resource is because sometimes services may stop on their own, and there is usually no easy way to tell if a service is still running, without opening the services console, querying via PowerShell, or checking in Server Manager.

Services like the Windows Firewall, or Component Services (ComSysApp) services will cause network problems they stop running. File Sharing between computers on the same network may fail if either of these services is stopped. The Windows Firewall (mpssvc)Service actually causes the most damage when it is not running, and sometimes it gets corrupted because of conflicting Group Policies or it may just stop. Although DSC is not going to be able to solve all problems that may cause the Windows firewall service to stop, it will be able to start the service and make sure it is running, barring any corruption or permission errors.

I often will set some of my machines up with DSC and the service resource to ensure that the ComSysApp is running, if I need to make sure that these computers are found on the network. The ComSysApp service is needed for some remote administration as well. Many times when I have been troubleshooting why a computer disappeared from the network or from remote administration, it has involved this service being stopped for some reason.


Example DSC Configuration using the new Service resource:

Configuration Server1service
{
Import-DscResource -ModuleName PsDscResources -ModuleVersion 2.1.0.0
{
Node Server1
{
Service ComPLUS
{
Name = "ComSysApp"
BuiltInAccount = "LocalSystem"
DisplayName = "COM+ System Application"
StartupType = "Automatic"
State = "Running"
}
Service RemoteReg
{
Name = "RemoteRegistry"
BuiltInAccount = "LocalService"
DisplayName = "Remote Registry"
StartupType = "Automatic"
State = "Running"
}
}
}
}

Server1Service -OutputPath C:\Dsc -Verbose

Start-DscConfiguration -ComputerName Server1 -Path C:\Dsc\ -wait -verbose

Advanced Desired State Configuration

Microsoft Virtual Academy’s Advanced Desired State Configuration course features Jeffrey Snover and Jason Helmick.

I wanted to post this a while ago, but I’ve been so busy with school and Project Management, that I keep having to put off finishing it. I recently finished completing the Advanced Desired State Configuration Powershell course in the Microsoft Virtual Academy, and it focuses on developing custom DSC Resources and implementing composite resources and partial configurations. Once again, Powershell inventor Jeffrey Snover and his sidekick Jason Helmick were funny and entertaining as they introduced custom Desired State Configuration resources, classes, and composite and partial configurations.

Once again, the scripts used in each of the modules are available in The Powershell Gallery, however to download and install the module you can use Powershell. If you have the WMF5.0 February preview installed, then simply open up the powershell ISE and type find-module *MVA* to find the module used for this course. The correct title is MVA_DSC_2015_Day_2. I recommend using the following command to install both modules:
find-module *MVA* | Install-Module

Once you have the module installed you can use the command Show-MVA_DSC_Examples -Day 2 -Module (#1-7), to open the commands and code in the Powershell ISE.

The second half of this course starts off with an introduction to building your own custom DSC resources. Jeffrey Snover and Jason Helmick actually both predict that 100% of all DSC users will actually build their own custom resources. I think that number may be just a little less, but creating custom resources is really not that difficult, you may have to watch these videos several times to get the hang of it however.

Now, you are going to want to download and unzip the DSCResourceKit Wave 10, although in the course they use Wave 9. However, each new wave just adds resources to the previous one, and fixes some bugs. In this case there were 8 new resources added, and several bugs were fixed. Extract the kit to a folder such as C:\Scripts.

To get the correct files in the Modules directory you are gonna need to extract the files from the resource kit into a folder and then go deep into the folder past the All Resources folder if you want to get it into the WindowsPowerShell Modules folder. The DSC Resource Kit Wave 10 can be downloaded in a zip file which is titled ‘DSC Resource Kit Wave 10 04012015.zip.’ If you extract the file you will get a folder with this title and a folder underneath that titled ‘All Resources’. Important: You are going to want to extract this folder anywhere and then copy everything Underneath the All Resources folder into ‘C:\Program Files\WindowsPowerShell\Modules’ and then you will have the resources in the modules folder. There really is no need to keep the folder “All Resources.” Once you put the resources in the modules folder, they will be available for use in the PowerShell ISE.

Now that you have the DSC Resources and the MVA modules you can get started created your own DSC resources with Jeffrey Snover and Jason Helmick in the MVA Advanced Desired State Configuration course. They go through demos of creating custom DSC resources, creating DSC resources using classes, and also partial or composite configurations as well. I would strongly recommend that anyone interested in Powershell Desired State Configuration to go to the Microsoft Virtual Academy website and watch these videos. Now, you also can use a new powershell module to download the videos directly to a folder on your hard drive. You can simply type
Find-Module 'Download-DSCVideos' | Install-module

and then you can run the following command Download-DSCVideos -dest ‘C:\DSCVideos’ -Advanced -verbose

Watch the MVA, download the DSC Resource Kit Wave10, and the WMF 5.0 April release is available in the Microsoft Download center: http://www.microsoft.com/en-us/download/details.aspx?id=46889.