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:

ps-day2a

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

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:

ps-day2c

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:

ps-day2d

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

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

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?

µ

10 Comments

  1. Kenneth J Hughes

    Thanks, Mike! Very complete, clear and concise. Just what I needed.

    Reply
  2. martinmilligan2015

    Thanks for this, as it made life a lot easier.

    Reply
  3. VintageMud

    Be aware this doesn’t work quite right if you have 4.6 installed.

    Reply
  4. Wayne Vetrone

    Is there a command line option to download and upgrade powershell without downloading it?

    Reply
    • Robert Hammett

      I have a similar question. I’m trying to determine if this is possible (or necessary for that matter) on Server 2008 R2 Core.`I’m usually pretty good at rewording my questions until the Internet gives up an answer.

      Reply
  5. Rolando Jara

    A restart would be required on Windows 2003 SP2 Servers after installing or upgrading the powershell version to 2.0 or later version?

    Reply
    • Mike F Robbins

      Yes. A restart is required on any server version when installing or updating PowerShell to a newer version.

      Reply
      • Ganesh Patil

        Mike,

        Are you sure,restart of server is must of powershell version 2.0 installation. I am looking for solution to deploy powershell 2.0 on Windows 2003 and 2008 servers without restart of servers.

        Regards,
        Ganesh Patil

        Reply
  6. Dinesh Salian

    Hi Mike,

    My name is Dinesh and i have been working on Powershell. I have a question for you regarding the System properties to be updated for around 50-60 desktops. I have updated the same by using powershell script and the same got reflected in AD. Will that be reflected too in local desktops or it would be only updated in AD.

    Thanks,
    Dinesh Salian.

    Reply
  7. Praveen

    Hi, We have a System having Windows 10 64-bit having Powershell version 2.0. Windows Updates are OFF by system Administrator.

    How do we Update Powershell 2.0 to 5.0 without using Windows Updates??

    Thanks,
    Praveen

    Reply

Leave a Reply

%d bloggers like this: