momius - Fotolia
How to upgrade to PowerShell 5
PowerShell version 5 is the most recent iteration of the scripting language and offers new features from previous versions. Admins can upgrade to the new version in a few steps.
Originally released as part of Windows 8.1 and Windows Server 2012 R2, Windows PowerShell version 4 brought about a ton of useful features. Since its release, it has been backward compatible down to Windows 7 and Windows Server 2008 and has been the recommended version to ensure compatibility across your scripts and to take advantage of the new features it had to offer. As of 2016, it's showing its age, and it's time to upgrade to the latest version -- PowerShell 5.
For this article, I will upgrade a Windows 8.1 client from PowerShell version 4 to the version 5 production preview. However, you can upgrade any Windows operating system down to Windows 7 SP1 and Windows Server 2008 R2.
PowerShell 5 is part of the Windows Management Framework (WMF) version 5 package. WMF requires the .NET Framework 4.5 package to be installed. You will need to install this before upgrading if you're trying to upgrade a Windows 7 or Windows Server 2008 computer. If you have Windows 8 or Windows Server 2012 or higher, .NET 4.5 is already included. To be sure, you can run the following command to see what version of the .NET Framework v4 you have installed.
(Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full').Version
If running this command gives an error about a missing registry key, this typically means you do not have a version of the .NET Framework 4.5 installed.
Some applications may not be compatible
Before you begin installation there are a few gotchas that are worth mentioning. First, some applications such as Microsoft SharePoint have hard dependencies on a specific PowerShell version. If you have scripts created and you suddenly upgrade the SharePoint server to a later version, the scripts will break. Other applications may have similar dependencies.
Also, even though the majority of your code built for earlier versions of PowerShell will work, there are some instances where PowerShell version 5 is just different enough to cause problems. The majority of problems will come with external dependencies like the aforementioned SharePoint server or vendors that haven't updated the code in their PowerShell support.
Installing PowerShell version 5
The first step is to download the installer. Be sure to pick the appropriate installer for your operating system. Windows 7, Windows 8.1, Windows Server 2008 R2, Windows Server 2012 and Windows Server 2012 R2 x86 and x64 all have separate downloads. If you attempt to install the wrong one, it will notify you upon installation.
Once you've got the bits downloaded, it's time to upgrade.
Double click on the installer you previously downloaded. You will be prompted to install the particular KB applicable to your operating system. Notice that the software title is Update for Windows (KBXXXXXXX). When installed, PowerShell will show up as being installed under this header in Programs and Features.
Confirm the upgrade, accept the end user license agreement and the installer will get to work.
When complete, it will ask you to reboot to confirm installation. Upon reboot, I always recommend confirming the install was successful. To do this, open up a PowerShell console again and type $PSVersionTable.PSVersion. If the install was successful, you should see the number 5 show up under the Major property.
Discover what's new with PowerShell 5
At this point, I suggest researching everything this version has to offer. Microsoft provides an overview of many of the most useful features and there are now numerous blog articles that go over many of the features that PowerShell version 5 brings. You might find that the code you wrote for older versions can now be replaced with more efficient, easier-to-read code that comes with PowerShell 5. It wouldn't hurt to go back through some of those old scripts you have that may be cumbersome to manage, or perform slowly, and research if any new features or fixes in PowerShell 5 may improve their worthiness.
Editor's note: Microsoft released PowerShell 5 to manufacturing on February 24.