Windows PowerShell Version Check

Check Your Version of PowerShell Windows PowerShell $PSVersionTable
with $PSVersionTable

PowerShell has a built-in variable called $PSVersionTable, it displays numeric information about the Version, Build and Compatibility.

 ♣

$PSVersionTable

This variable was first introduced in PowerShell version 2.0.

# Windows PowerShell Version Check.
$PSVersionTable

Name 			Value 
---- -----
PSVersion 4.0
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
CLRVersion 4.0.30319.18408 BuildVersion 6.3.9600.16406
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion 2.2

Note 1: PSVersion is 4.0

Note 2: CLRVersion means Common runtime version.

Note 3: BuildVersion varies depending on the underlying operating system.

Detailed PowerShell Version Check

Here is a more detailed version check on the PowerShell executable.

# Windows PowerShell Version Check
Clear-Host
$PSVersionTable.PSVersion

Major 	Minor 	Build 	Revision 
  4 	  0 	  -1  	  -1 

Guy Recommends:  A Free Trial of the Network Performance Monitor (NPM)Review of Orion NPM v11.5 v11.5

SolarWinds' Network Performance Monitor will help you discover what's happening on your network.  This utility will also guide you through troubleshooting; the dashboard will indicate whether the root cause is a broken link, faulty equipment or resource overload.

What I like best is the way NPM suggests solutions to network problems.  Its also has the ability to monitor the health of individual VMware virtual machines.  If you are interested in troubleshooting, and creating network maps, then I recommend that you try NPM now.

Download a free trial of Solarwinds' Network Performance Monitor

$Host - PowerShell Variable

Here is an alternative method to check your version of Windows PowerShell.

# Windows PowerShell Version Check
$Host

Name: 			Windows PowerShell ISE Host
Version: 4.0 InstanceId: d36fdafd-f9e9-4642-bc85-6dea29105f61
UI: System.Management.Automation. Internal.Host.InternalHostUserInterface
CurrentCulture: en-GB
CurrentUICulture: en-US
PrivateData: Microsoft.PowerShell.Host.ISE.ISEOptions
IsRunspacePushed: False Runspace: System.Management.Automation. Runspaces.LocalRunspace

Note 4: As with PSVersionTable, the PowerShell Version is 4.0

Checking Your .Net Version

Here is a script which interrogates the NET Framework section of the registry.

Clear-Host
Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -Recurse |
Get-ItemProperty -Name Version -EA 0 |
Where { $_.PSChildName -Match '^(?!S)\p{L}'} |
Format-Table PSChildName, Version -AutoSize

PSChildName                      Version       
-----------                      -------       
v2.0.50727                       2.0.50727.5420
v3.0                             3.0.30729.5420
Windows Communication Foundation 3.0.4506.5420 
Windows Presentation Foundation  3.0.6920.5011 
v3.5                             3.5.30729.5420
Client                           4.5.50938     
Full                             4.5.50938     
Client                           4.0.0.0     

Note 5: Observe the use of -Recurse to drill down to the sub keys. 

Note 6: Check the REGEX pattern matching: '^(?!S)\p{L}'

Recommended: Solarwinds' Permissions Analyzer - Free Active Directory ToolFree Permissions Analyzer for Active Directory

I like the Permissions Analyzer because it enables me to see WHO has permissions to do WHAT at a glance.  When you launch this tool it analyzes a users effective NTFS permissions for a specific file or folder, and takes into account network share access, then displays the results in a nifty desktop dashboard!

Think of all the frustration that this free SolarWinds utility saves when you are troubleshooting authorization problems for user's access to a resource.  Give this permissions monitor a try - it's free!

Download SolarWinds' Free Permissions Analyser - Active Directory Tool

Running PowerShell 4.0 as Version 2.0Windows PowerShell Version Check

My main reason for downgrading the version from 4 to 2 is for testing.  What I do is create a shortcut, and append -Version 2 to 
Target: ..\powershell.exe -version 2. 

Incidentally, Windows PowerShell is always installed in a sub-folder called v1.0.

Note 7: The syntax requires a space either side of -version.

Note 8: If you try -version 1 you still get PowerShell version 2!

Note 9: PowerShell v4 installs in a sub-directory called \v1.0\ (see above).

Name 			Value 
CLRVersion 2.0.50727
BuildVersion 6.1.7601
PSVersion 2.0
WSManStackVersion 2.0
PSCompatibleVersions {1.0, 2.0}
SerializationVersion 1.1.0.1 PSRemotingProtocolVersion 2.1

Other Useful PowerShell Testing Techniques

# PowerShell Version Test
Clear-Host
If ($PSVersionTable.PSVersion.Major -gt 3) {Write-Host "Supports PowerShell Version 4"}
Else {Write-Host "Only supports version 3"}

Note 10:  When experimenting, you could substitute more useful code for "Supports Version 4"

See more PowerShell built-in variables »

Summary of PowerShell's $PSVersionTable

Check your version of PowerShell with $PSVersionTable or $Host.  You can also append a -version 2 switch to run PowerShell 3 as a previous version.

If you like this page then please share it with your friends

 


See more Windows PowerShell tutorials

PShell Home   • Introduction   • Dreams   • 3 Key Commands   • PowerShell Help About   • Get-Help

PowerShell v 3.0   • Set-ExecutionPolicy   • Get-Command   • Cmdlet scripts   • Import-Module

PowerShell Version Check   • Backtick   • PowerShell examples   • PowerShell ISE   • Get-Member

Please email me if you have a better example script. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.

 

 *


Custom Search

Site Home

Guy Recommends: WMI Monitor for PowershellSolarwinds WMI Monitor

Windows Management Instrumentation (WMI) is most useful for PowerShell scripting.

SolarWinds have produced this Free WMI Monitor to take the guess work out of which WMI counters to use for applications like Microsoft Active Directory, SQL or Exchange Server.

Download your free copy of WMI Monitor

Author: Guy Thomas Copyright © 1999-2016 Computer Performance LTD All rights reserved.

Please report a broken link, or an error to: