Be sure to start off by reading my previous blog article titled Error When Running PowerShell -Version 2 on Windows 8 and Windows Server 2012 if you have not previously read it since attempting to run PowerShell in version 2 mode generates an error on a default installation of Windows 8 or Windows Server 2012.
In PowerShell version 3, you can access PowerShell version 2 by running “PowerShell.exe -Version 2” (or “powershell -v 2”):
Windows 8 Release Preview
The PowerShell version 2 functionality is an optional feature that’s enabled by default:
PowerShell (or the GUI as shown above) can be used to display these optional features:
#Display the operating system version to show this is Windows 8 Release Preview: (Get-CimInstance -ClassName Win32_OperatingSystem).Caption #List the features that are currently enabled: Get-WindowsOptionalFeature -Online | where State -EQ 'enabled'
The thing I don’t like about the Get-WindowsOptionalFeature cmdlet that I used in the previous example is that its FeatureName parameter doesn’t accept wildcards or an array of strings which makes that particular parameter almost useless:
It’s possibly to remove the PowerShell version 2 functionality by disabling those features:
Disable-WindowsOptionalFeature -Online -FeatureName 'MicrosoftWindowsPowerShellV2', 'MicrosoftWindowsPowershellV2Root'
At least the Disable-WindowsOptionalFeature cmdlet supports an array of strings so you can disable more than one feature at the same time. Enable-WindowsOptionalFeature also supports an array of strings.
Windows Server 2012 Release Candidate
PowerShell version 2 doesn’t show up in the GUI (if you performed the full GUI installation of the OS) as a feature that can be disabled, but it does show up in PowerShell:
#Display the operating system version to show this is Windows Server 2012 Release Candidate: (Get-CimInstance -ClassName Win32_OperatingSystem).Caption #List the features that start with PowerShell: Get-WindowsFeature -Name PowerShell*
As with Windows 8, the PowerShell version 2 functionality can be disabled in Windows Server 2012 by disabling this feature:
My previous blog (referenced in the first paragraph of this blog) includes more information about the new Install-WindowsFeature and Uninstall-WindowsFeature cmdlets.