Getting PowerShell 5 April Preview (5.0.10105) Running Windows 7 and Server 2008 R2 (some assembly required) Print E-mail
PowerShell
Written by Darwin Sanoy   
Thursday, April 30, 2015 8:48pm

I am very excited that the PowerShell team has just delivered the April Preview that allows version 5 to run on Windows 7 SP1 and Server 2008 R2 (PowerShell Version 5.0.10105).  For this preview version there are a few foibles to getting it running on Windows 7.  The PowerShell team hopes to sort these out, but in the mean time I have put together a quick config that steps you though everything with one command line.

 

 

Windows 7 and Server 2008 R2 are the worst case scenarios and therefore are the focus of the below, however, all of these steps work for Server 2012, 2012 R2 and Windows 8.1 - they take fewer steps because they have more of the prerequisites.

Here are the challenges in getting a Windows 7 or Server 2008 R2 machine to PowerShell 5:

  1. You must have SP1.  If you are using source media that does not have it slipstreamed (like the downloadable Server 2008 R2 VHD), then you'll need to apply it before getting started.
  2. You must have .NET 3.5.1 or later to install PowerShell 4.  However, the PowerShell 4 installer does not block you if you don't have it.  It successfully installs and then when you reboot you are still on your previous version (2 or 3).  You have to uninstall the PowerShell 4 Windows Update and then install .NET 4.5.1 and then reinstall PowerShell 4.  If you use the quick config below - this is detected for you and you are instructed to issue a chocolatey command to easily pull .NET 4.5.1 onto your system.
  3. You must first install PowerShell / WMF 4 before you can install PowerShell / WMF 5.  This is an interim dependency that the PowerShell team is planning to eliminate for the production release.  However, if you try to install PowerShell 5 without 4 present, you just get a standard Windows Update WUSA error "This Update is not applicable to your system" (Error: 2149842967 or 0x80240017).  PowerShell 5 installs via one of the following windows updates: KB3055381, KB3055377 or KB2908075.  The below quick config also detects this situation and installs PowerShell 4 and instructs you to reboot and re-run the quick config.
  4. Finally you can install PowerShell 5.

The below quick config uses the Chocolatey package for PowerShell that I have updated for the April preview.  If you already know your way around Chocolatey, then you can simple keep re-running that package with -force until PowerShell 5 is on your system.  Before you start you will need to have SP1 loaded and use "choco install -y dotnet4.5.1" to get the minimum .NET version installed.  Then use "choco install -y powershell -pre -force" at least two times.

If you've never heard of Chocolatey, no problem.  You can run a PowerShell script from a public github file I have created and it will install chocolatey for you.  You can just keep running it repeatedly to get PowerShell 5 on your system and then at the end you can optionally install the latest PowerShell dsc resources from PowerShellGallery.com.

This quick config is intended for lab and test machines - it installs the Chocolatey package manager and sets your PowerShell execution policy to RemoteSigned.

You can see the complete source of the script before running here: https://raw.githubusercontent.com/CSI-Windowscom/Bootstraps/master/QuickConfigPowerShell5.ps1

Here are the quick config steps:

  1. Open a PowerShell console as Administrator.
  2. Paste this command line into the console (one line): 

    iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/CSI-Windowscom/Bootstraps/master/QuickConfigPowerShell5.ps1'))

    If you receive an error that contains "...The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel." it's likely you are on PowerShell 2.0 and will need to use this longer command line (one line):

    [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {[bool]1};iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/CSI-Windowscom/Bootstraps/master/QuickConfigPowerShell5.ps1'));[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {[bool]0}

  3. Each time the system reboots, re-run the above command line.  In most cases two reboots wil get you to PowerShell 5 on Windows 7 SP1 or Server 2008 R2.
  4. On the last time you re-run it, you will be prompted whether to download all the latest versions of the DSC Resources on PowerShellGallery.com - this is optional and generally used for a lab machine for getting started with DSC.

If you find any problems with the quick config - be sure to send me a note.

D.

The underlying connection was closed: Could not establish tru st relationship for the SSL/TLS secure channel.