PowerShell tutorial – How to know the current version of PowerShell on my system

PowerShell CMDLETs to know the current PowerShell version
PowerShell CMDLETs to know the current PowerShell version

Hi All,

Greetings for the day.

Today small but important sharing

In this small article we will discuss about – knowing PowerShell version installed on my system

Background – Why I want to know the PowerShell version

  • As PowerShell administrator or I am writing PowerShell scripts I must know the version of PowerShell
  • As an Administrator, some time we need to install PowerShell on any platform – Linux / Mac
  • As PowerShell Administrator / Developer to know the features available in given version
  • This is also important to maintain SECURITY – latest version of PowerShell often includes security patches , bug fixes, vulnerability fixes
  • To maintain performance, newer version may includes performance enhancements, which maintains the efficiency of our scripts

Details:

  • Open the PowerShell ISE
  • Use Search bar to find correct “Windows PowerShell ISE” app as shown in below fig
Microsoft PowerShell - opening Windows PowerShell ISE
fig : Microsoft PowerShell – opening Windows PowerShell ISE
  • As you opens the “Windows PowerShell ISE” it look like
Microsoft PowerShell - Windows PowerShell ISE
fig : Microsoft PowerShell – Windows PowerShell ISE

Using $PSVersionTable variable

  • To know the current PowerShell version, we will use – $PSVersionTable as in below snippet.
  • This is the most reliable method to know the version of PowerShell

$PSVersionTable

Output:

Name                           Value                                                                                                        
----                           -----                                                                                                        
PSVersion                      5.1.22621.2506                                                                                               
PSEdition                      Desktop                                                                                                      
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                      
BuildVersion                   10.0.22621.2506                                                                                              
CLRVersion                     4.0.30319.42000                                                                                              
WSManStackVersion              3.0                                                                                                          
PSRemotingProtocolVersion      2.3                                                                                                          
SerializationVersion           1.1.0.1

Microsoft PowerShell - Executing - PSVersionTable - Knowing the current version of PowerShell
fig : Microsoft PowerShell – Executing – PSVersionTable – Knowing the current version of PowerShell

Using get-host variable

  • We could also use CMDLET – get-host to know the details of current PowerShell version as
get-host

Output:

Name             : Windows PowerShell ISE Host
Version          : 5.1.22621.2506
InstanceId       : 2e2c52f7-904a-4c53-8248-393c9dcaa3ec
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.Host.ISE.ISEOptions
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Microsoft PowerShell - Executing - get-host - Knowing the current version of PowerShell
fig : Microsoft PowerShell – Executing – get-host – Knowing the current version of PowerShell

Using $host variable

  • We have an also option using – $host as – returns the same result as get-host
$host

Output:

Name             : Windows PowerShell ISE Host
Version          : 5.1.22621.2506
InstanceId       : 2e2c52f7-904a-4c53-8248-393c9dcaa3ec
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.Host.ISE.ISEOptions
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

From Command Prompt

  • Open the command prompt
  • Type “cmd” in Windows Run box (Win + R)
  • Command prompt will be opened as in below snap
  • We will use “Powershell.exe” to execute PowerShell CMDLETs
Microsoft PowerShell - Executing - get-host - Knowing the current version of PowerShell from Command Prompt
fig : Microsoft PowerShell – Knowing the current version of PowerShell from Command Prompt

From Registry

  • The registry location “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine” stores the PowerShell version in the string “PowerShellVersion” on 64-bit Windows as shown in below snap
Microsoft PowerShell - Knowing the PowerShell version details from Registry
fig : Microsoft PowerShell – Knowing the PowerShell version details from Registry

OR we could also use PowerShell CMDLET – Get-ItemPropertyValue as

Get-ItemPropertyValue -Path HKLM:\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine -Name PowerShellVersion

Microsoft PowerShell - Knowing the PowerShell version details from Registry using Get-ItemPropertyValue
fig : Microsoft PowerShell – Knowing the PowerShell version details from Registry using Get-ItemPropertyValue

Thanks for reading ! Stay tuned for more articles on PowerShell !

HAPPY LEARNING AHEAD 🙂 LIFE IS BEAUTIFUL 🙂

Prasham Sabadra

LIFE IS VERY BEAUTIFUL :) ENJOY THE WHOLE JOURNEY :) Founder of Knowledge Junction and live-beautiful-life.com, Author, Learner, Passionate Techie, avid reader. Certified Professional Workshop Facilitator / Public Speaker. Scrum Foundation Professional certificated. Motivational, Behavioral , Technical speaker. Speaks in various events including SharePoint Saturdays, Boot camps, Collages / Schools, local chapter. Can reach me for Microsoft 365, Azure, DevOps, SharePoint, Teams, Power Platform, JavaScript.

You may also like...

1 Response

  1. January 25, 2024

    […] We have detailed article for verifying PowerShell version – please have a look – PowerShell tutorial – How to know the current version of PowerShell on my system – https://microsoft365hub.in/2024/01/25/powershell-tutorial-how-to-know-the-current-version-of-powersh… […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Microsoft 365

Subscribe now to keep reading and get access to the full archive.

Continue reading