Installing WMF 5.0 Preview September 2014 using DSC xWindowsUpdate resource
If you have missed the announcement, Powershell team released wave 7 of the DSC Resource Kit just before the weekend.
This wave has added the following:
- xPendingReboot examines three specific registry locations where a Windows Server might indicate that a reboot is pending and allows DSC to predictably handle the condition
- xCredSSP enables or disables the server and client CredSSP roles on a system.
- xAdcsCertificationAuthority this resource installs and configures the Certificate Authority role on a Windows Server.
- xAdcsWebEnrollment this resource configures Certificate Services Web Enrollment on a Windows Server following installation of the component using the WindowsFeature resource.
Out of the four new DSC resources, the xPendingReboot resource is of immediate use for me. I build VMs for my lab quite often and having the newest DSC bits is a must for me. And, what is the better way than using DSC for installing WMF? 🙂
If you have installed WMF bits in the past, you will know that it requires a reboot at the end of installation procedure. xHotfix resource in the xWindowsUpdate module triggers a reboot if a Windows update requires doing so. This is where xPendingReboot is useful. If Local Configuration Manager (LCM) is already configured to reboot the node as needed (RebootNodeIfNeeded is set to True), this resource can be used to induce the restart after WMF install. This resource does that by changing the $Global:DSCMachineStatus variable to 1.
So, here is the configuration script I created for the purpose of installing WMF 5.0 bits on my lab systems. This requires xPendingReboot and xWindowsUpdate resource from the DSC Resource Kit.
Update: xHotfix can reboot a system if a Windows Update package install requires reboot. Therefore, using xPendingReboot is not necessary.
Note: DSC Resource Kit wave 7 release excluded the xWindowsUpdate resource for some reason. If you don’t have it on your system, you can download it from http://gallery.technet.microsoft.com/xWindowsUpdate-Module-with-5af00a7f. Also, note that these resources must be present on the target systems where you are installing WMF 5.0 using DSC.
Update: xWindowsUpdate resource is now added to the wave 7 resource kit download.
Once you have the DSC resources copied to the VM, you can use the following configuration script that I created for installing WMF 5.0 using xWindowsUpdate and xPendingReboot resources.
Configuration WMF5Sep14Install
{
Import-DscResource -ModuleName xWindowsUpdate, xPendingReboot
Node localhost
{
xHotfix HotfixInstall
{
Path = 'C:\Hotfix\KB2969050-x64.msu'
Id = 'KB2969050'
Ensure = 'Present'
}
}
}
WMF5Sep14Install
In the above example, I have downloaded the MSU package and stored it in C:\Hotfix folder. So, I provided that path as the value of Path property in the xHotfix resource configuration. When we enact this configuration using the Start-DscConfiguration cmdlet, we will see that the MSU gets installed and then a reboot gets induced if you have set the LCM to reboot as needed or a message will be displayed that a reboot is pending.
WMF 5.0 in this article is just an example. You can use this method to perform any number of MSU installs and actually perform the reboot as required.
Share on: