PowerShell tutorial – How to know the current version of PowerShell on my system
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
- As you opens the “Windows PowerShell ISE” it look like
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
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
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
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
OR we could also use PowerShell CMDLET – Get-ItemPropertyValue as
Get-ItemPropertyValue -Path HKLM:\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine -Name PowerShellVersion
Thanks for reading ! Stay tuned for more articles on PowerShell !
HAPPY LEARNING AHEAD 🙂 LIFE IS BEAUTIFUL 🙂
1 Response
[…] 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… […]