The latest released version of WMF 5.0 is the April 2015 preview. It's good to read the release document, refer the following link: https://www.microsoft.com/en-us/download/details.aspx?id=46889
The PowerShell team releases experimental DSC resources to configure an environment, and the latest DSC resource kit is Wave 10. Let's download this from the TechNet Gallery website (https://gallery.technet.microsoft.com/scriptcenter/DSC-Resource-Kit-All-c449312d) to install WMF 5.0 because we need the xHotfix resource to perform this action. We will discuss all about the DSC resources later in this chapter.
Note that from April 2015 onward, the DSC resource kit has been outsourced to GitHub.
The central repository for DSC resources can be found at https://github.com/powershell/DscResources.
In this example, we will install the MSU file for WMF 5.0 using DSC; to do this, we will use the Configuration
keyword with the following script block:
Configuration WMF5 { Import-DscResource -ModuleName xWindowsUpdate Node localhost { xHotfix WMFInstall { Path = 'C:UsersChenVDownloadsWindows6.1-KB2908075-x64.msu' Id = 'KB2908075' Ensure = 'Present' } } } WMF5
How does this work? Take a look at the following image:
The points marked in the figure are explained in the following list:
Configuration
keyword and keyword and block.xWindowsUpdate
. Import-DscResource
should be inside the configuration block.Path
, ID
, and Ensure
.After creating the MOF file, we can apply the configuration using Start-DscConfiguration
. Wait! First, let's do some additional setting up, such as updating the help, execution policy, WinRM services, and so on. Take a look at the following code. It will update the help files, modify the execution policy to RemoteSigned
, and Set-WSManQuickConfig
in it will do the following:
By default, WinRM is enabled in Windows Server 2012 and Windows 8.1. We will perform this action here because we will be using Windows Server 2008 R2 SP1.
Start-DscConfiguration
will apply the configuration on the target node, which is our localhost. Run the following command:
Update-Help -Verbose Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Verbose Set-WSManQuickConfig -Verbose Start-DscConfiguration .WMF5 -Wait -Force -WhatIf
Let's take a look at the output of Start-DSConfiguration
:
The points marked in the figure are explained in the following list:
C:WindowsTemp
wsusa.exe
After a reboot, we can see that the updates are being installed, as in the following image:
We have applied the configuration successfully; the box is in WMF 5.0, as shown in the following image: