Deploy WMF5.0 on Windows 7

When the WMF5.0 was republished, I’ve asked the following question in the comments

Can you please explain why WMF 4.0 is a prerequisite on Windows Server 2008 R2 and Windows 7 SP1? Is it related to the WMI repository and/or to DSC?

Krishna C Vutukuri from the Windows PowerShell Team replied

As you may know, WMF 5 uses CBS based technology for installation. Win 7 SP1/W2K8R2 systems contain PowerShell 2.0, WinRM, WMI by default. After Win7/W2K8 R2 released, we shipped WMF 3.0 and WMF 4.0 which contain updates to these features. Installing / Uninstalling these packages uncovered some issues in the upgrade options from inbox -> WMF4 and inbox->WMF3->WMF4. We fixed all those issues in WMF4. Hence we had to make WMF4 as requirement for installing WMF5 on Win7 SP1/W2K8 R2. Here are the specific issues you might face if you do not install WMF4 before upgrading to WMF5:

(a) Forwarded Events log is unavailable and EventCollector log is not displayed in Event Viewer after you uninstall in Windows 7 SP1 and in Windows Server 2008 R2 SP1
(b) Issues with PSModulePath environment when you upgrade directly from inbox to WMF5 or from WMF 3 to WMF5.

Again WMF4 addresses these issues and our internal testing environment uses this matrix for testing WMF5 on Win7 SP1/W2K8R2 SP1.

Thanks
Krishna
Windows PowerShell Team

The other person interested in the upgrade path to WMF 5.0 on Windows 7 asked about
WMF4-update

To summarize: Windows 7 SP1 is shipped with PowerShell 2.0 and .Net 3.5 SP1 and to upgrade it to PowerShell 5.0, you’ve to:

  1. fullfil the .Net 4.x requirement
  2. update to WMF 4.0
  3. reboot
  4. update to WMF 5.0
  5. reboot

Ok, .Net 4.5.2 or .Net 4.6.x and WMF 5.0 can deployed from Microsoft Update but how to deploy WMF 4.0?

I’m not the only one who noticed this shortcoming. Bjorn Houben says on his blog:

One of the disadvantages however is that for operating systems before Windows 8.1/2012, a prerequisite is that WMF4 is installed, which cannot easily be deployed using WSUS unfortunately.

Martin Schvartzman @MSFT discussed how to deploy WMF 4.0 on this page.

Although I’ve got ConfigMgr in my environment, I wanted to find a solution

  • that doesn’t have any dependency (except Internet connectivity),
  • that would deploy .Net 4.5.2 if missing but that wouldn’t fail if it has .Net 4.6 or 4.6.1,
  • that would minimize the number of restarts required,
  • that will install the required components silently and not force a restart

My code somehow illustrates the concept of immutable infrastructure that Jeffrey Snover talked about in a recent video.

[…] All your infrastructure is the result of a base set of components and an algorithm to produce a result. If you don’t like the result or ever need to make a change, you never change the instance, you go back, change the recipe, re-run it to produce the instance. […]

My code is a recipe to ease the pain of getting Windows 7 from its built-in PowerShell 2.0 to WMF 5.0.
It’ll drive you through the following different stages:

    • Run it for the first time with all components missing, it will install .Net 4.5.2
    • wmf2towmf5-stage1

      Re-run it and it moves to the next step and installs WMF 4.0
      wmf2towmf5-stage2

    • Re-run it and it will kindly tell you that a reboot is pending
    • wmf2towmf5-reboot1

    • Re-run it after the 1st restart, it will move on and install WMF 5.0
    • wmf2towmf5-stage3

    • Re-run it after the 2nd restart and it will do nothing except telling you that WMF 5.0 is already installed
    • wmf2towmf5-final

Here’s the code (gone through the PSScriptAnalyzer module that only flagged it for using the Get-WmiObject cmdlet)

No doubt that PowerShell rocks and that it’s a key component to immutable infrastructure ๐Ÿ˜Ž

Advertisements

4 thoughts on “Deploy WMF5.0 on Windows 7

  1. Pingback: Dew Drop – May 18, 2016 (#2254) | Morning Dew

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s