Installing the WMF 5.0 April 2015 preview

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:

Installing the WMF 5.0 April 2015 preview

The points marked in the figure are explained in the following list:

  • 1: Here, we use the Configuration keyword and keyword and block.
  • 2: Here, we import the experimental DSC resource, xWindowsUpdate. Import-DscResource should be inside the configuration block.
  • 3: Here, we declare the node. We will use the localhost.
  • 4: Here, we use the xHotfix DSC resource and give it a friendly name.
  • 5: Here, we declare the DSC properties—Path, ID, and Ensure.
  • 6: Here, we call the configuration to create an MOF file. As you did with the function, use a friendly name.
  • MOF Created: Here, we have successfully created our MOF file.

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:

  • It will check whether the WinRM service is running. If it is not running, the service will be started.
  • It will set the WinRM service startup type to automatic.
  • It will create a listener that will accept requests on any IP address. By default, the transport is HTTP.
  • It will enable a firewall exception for the WinRM traffic.

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:

Installing the WMF 5.0 April 2015 preview

The points marked in the figure are explained in the following list:

  • 1: Here, the configuration is started
  • 2: Here, a test is performed to check whether the hotfix is present
  • 3: Here, the path is validated
  • 4: Here, it shows the time consumed for validation
  • 5: Here, since we haven't provided the log path, DSC creates a log file in C:WindowsTemp
  • 6: Here, the MSU installation happens using wsusa.exe
  • 7: Here, the installation is completed
  • 8: Here, it shows the total time consumed to apply the configuration

After a reboot, we can see that the updates are being installed, as in the following image:

Installing the WMF 5.0 April 2015 preview

We have applied the configuration successfully; the box is in WMF 5.0, as shown in the following image:

Installing the WMF 5.0 April 2015 preview
..................Content has been hidden....................

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