Having been tasked with the upgrade of Windows PowerShell from version 2.0 to version 3.0 on a bunch of Windows 2008 R2 servers, I thought I could share my experience with this kind of activity and help you not to get muddled up. I will try to be as clear as possible and detail the steps to follow as well as identify the milestones of the upgrade.
First of all know that Windows PowerShell 3.0 is part of a greater package known as Windows Management Framework (WMF 3.0). WMF contains Windows PowerShell 3.0 (of course...), WMI and WinRM. The Beta version also includes a Server Manager CIM provider. This CIM provider allows users of Server Manager in Windows Server 2012 to collect and view management data from servers with Windows Management Framework 3.0 installed.
The Beta version of WMF 3.0 is shipped in four different packages. The package we are interested to is Windows6.1-KB2506143-x64.msu, which is targeted for Windows 2008 R2 SP1. You can download it from this link.
Before we start the upgrade, check that four prerequisites are met:
- you have SP1 ( if not, download the pretty huge (903MB) file here)
- you are running the x64 edition (Windows 2008 R2 exists only in 64 bit...)
- you have installed the full version of .NET 4.0 (available here for Full Windows installation and here if you have the the Server Core version of Windows 2008 R2 SP1)
- if you are using a non-English version of Windows, you must first install the English Language Pack.
If you don't have the .NET Framework 4 installed on your Server 2008 R2 but you try to install it you'll get a “The update is not applicable for your system” message box:
If you are unsure about the .NET version you own, check whether the registry key HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full contains the 'Install' registry entry with a value of 1. If so, then .NET 4 is already there.
In a fresh Windows 2008 R2 without Service Pack 1 you will find that:
- the key for .NET is called: HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727
- the output of (get-host).version telling your current PowerShell version is: 'Version : 2.0'
- the build of WM, retrieved with gwmi -class Win32_WMISetting, is '7600.16385'
After installing SP1, one value changes:
- gwmi -class win32_wmisetting returns '7601.17514'
After installing .NET 4
- a new key for .NET 4 is added: HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4
A last check to PowerShell 2.0 features in order to compare later:
- (gcm).count returns 410
- (get-alias).count returns 137
- (Get-Module -ListAvailable).count returns 7
- (Get-PSSnapin).count returns 7
Now let's run the PowerShell installer, Windows6.1-KB2506143-x64:
Complete the installation and restart.
Once the server is restarted, launch PowerShell and you'll immediately see that it has upgraded to version 3.0 by querying the $host variable:
Name : ConsoleHost
Version : 3.0
InstanceId : b1ace04c-20a5-4560-a6d5-37d4fc74b37c
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentUICulture : en-US
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxyIsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace
Let's count the available cmdlets, aliases, modules and snapins:
- (gcm).count returns 366
- (get-alias).count returns 148
- (Get-Module -ListAvailable).count returns 18
- (Get-PSSnapin).count returns 1
Apparently there are less cmdlets in PowerShell 3.0 than in 2.0 but this is false. In V2 gcm (alias for get-command) returns cmdlets, functions and aliases, while in V3 it returns cmdlets and functions only.
In reality there are 236 cmdlets in V2 (the right query for V2 is '(gcm -CommandType cmdlet).count') and 313 in V3.
I hope you have found this post interesting. I will talk a litlle more about new cmdlets in V3 in a future post. Stay tuned!