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 |
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:
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:
1 | Get-WmiObject -Class Win32_OperatingSystem | Format-Table Caption, ServicePackMajorVersion -AutoSize |
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*' |
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:
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:
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?
µ
Thanks, Mike! Very complete, clear and concise. Just what I needed.
Thanks for this, as it made life a lot easier.
Be aware this doesn’t work quite right if you have 4.6 installed.
Is there a command line option to download and upgrade powershell without downloading it?
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.
A restart would be required on Windows 2003 SP2 Servers after installing or upgrading the powershell version to 2.0 or later version?
Yes. A restart is required on any server version when installing or updating PowerShell to a newer version.
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
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.
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
WMF 5.1 is the latest version :
https://www.microsoft.com/en-us/download/details.aspx?id=54616
Thanks! Your .NET Framework Validation PS script could use updating though, as 4.6 is out. (Get-ItemProperty -Path ‘HKLM:\Software\Microsoft\NET Framework Setup\NDP\v4\Full’ -ErrorAction SilentlyContinue).Version -like ‘4.[56789]*’
This way you get “True” for every version greater than 4.4*…
Great post. I have taken it one step further due to necessity. Some versions of PowerShell/WMF are not compatible with server software so I did a little deeper to see if Exchange, SMA, etc are installed on the box as well.
Care to share what you’ve found?
Hi, this solution havent worked for me with win7 professional pack1, Have you another solution to follow please write me!
Any way to upgrade PowerShell v.2 on Server2008R2 in secure environment with no access to the outside?