How to check the PowerShell version & install a new version

In my last blog article I demonstrated Where to Find & How to Launch PowerShell.

Today I'll continue on to the next step which is determining what version of PowerShell you have installed. PowerShell version information is contained in the $PSVersionTable automatic variable.

You can type out $PSVersionTable in the console window that you opened in the last blog article or you can type $psv and press tab to take advantage of what's called tabbed expansion:

1$PSVersionTable

ps-day2a.jpg

In the previous example I checked the PowerShell version on a computer running Windows 7 that has the default version of PowerShell installed that Windows 7 ships with which is PowerShell version 2.

While PowerShell version 2 is still a viable solution and your only option if you're still running Windows Server 2003 or Windows Vista, there's very few reasons not to upgrade to a newer version of PowerShell if your operating system supports it.

There are certain versions of Exchange, System Center, and various other applications or third party products that you may have installed which may not support a newer version of PowerShell or the .NET Framework version upgrade that is required so check with your application vendors before proceeding with upgrading to a newer version of PowerShell.

Warning: You should always test new software (to include a new version of PowerShell) in a test environment before installing it on a production system. Do not install preview versions of PowerShell in a production environment <period>.

Here's a slide from one of my presentations that shows what PowerShell versions ship with all of the currently supported Microsoft operating system versions:

ps-day2b.jpg

I'll download and install PowerShell version 4 on the Windows 7 computer that's being used in this blog article. PowerShell is distributed as part of the Windows Management Framework which you'll sometimes see the acronym WMF for.

Download the Windows Management Framework 4.0. Read through the system requirements and make sure that your system meets the requirements. Windows 7 requires that service pack 1 be installed so let's validate it's installed:

1Get-WmiObject -Class Win32_OperatingSystem | Format-Table Caption, ServicePackMajorVersion -AutoSize

ps-day2c.jpg

The full version of the .NET Framework 4.5 is also a prerequisite. A simple PowerShell one-liner can be used to check to see whether or not it's installed:

1(Get-ItemProperty -Path 'HKLM:\Software\Microsoft\NET Framework Setup\NDP\v4\Full' -ErrorAction SilentlyContinue).Version -like '4.5*'

ps-day2d.jpg

As you can see in the previous results, the .NET Framework 4.5 is not currently installed. Keep in mind that the full version of the .NET Framework 4.5 is required and the client version is not sufficient. You'll receive the error The Update is Not Applicable to Your Computer if the client version is installed and not the full version when trying to install the Windows Management Framework 4.0.

I've downloaded and installed the .NET Framework 4.5 so let's rerun the last command to see if it now returns true:

ps-day2f.jpg

Indeed it does.

I've now installed the Windows Management Framework 4.0. A restart was required after the installation finished. Let's check the PowerShell version again:

ps-day2g.jpg

PowerShell version 4 has been successfully installed on the Windows 7 computer used in the demonstration in this blog article. Yes, it's that easy so why are you still using an older version of PowerShell?

µ