# Getting PowerShell 5 Running on Windows 7 and Server 2008 R2

### 2017-01-30 Update - the steps in this article are no longer necessary

WMF 5.1 now installs directly on top of WMF 3, however it can lose your PSModulePath customizations in the process. I have attempted to address this in the Chocolatey package I help maintain for the PowerShell package on Chocolatey.org. If you don’t use Chocolatey (I feel sorry for you ;) ), you can just steal my PowerShell code that does this piece of the puzzle from the here: https://github.com/IntelliTect/Chocolatey.Packages/blob/master/PowerShell/v5.1/tools/ChocolateyInstall.ps1#L109-L178

If you do use Chocolatey, you can simply do this:

choco install powershell -confirm -force


## Original Article:

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, howver, 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. Most cloud based VMs should have SP1 on Server 2008 already.

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 -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 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 remote signed.

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'))

3. Each time the system reboots, re-run the above command line. In most cases two reboots will 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.