4 Ways to Check the Current PowerShell Version on Your PC

Introduction

If you are reading this guide because you want to learn how to find the PowerShell version on your computer, you are in the right place!

This guide details 4 ways you can check the version of PowerSell on your computer.

4 Ways to Get the PowerShell Version on your PC

If you want to determine the version of PowerShell on your computer, use one of the methods/commands discussed below:

Method 1: Get PowerShell Version with $PSVersionTable Automatic Variable

Copy and paste the command below into a PowerShell console and press Enter

$PSVersionTable

Here is the result

 

My current PS version is 5.1.17134.858 but the result contains other information which you may not need.

To display just the version number, use the command below

$PSVersionTable.PSVersion

Here is the result

 

The last command provides a bit more information. We now know that 5, 1, 17134, 858 represents Major, Minor, Build and Revision numbers.

To display just the Major number, use this command:

$PSVersionTable.PSVersion.Major

Method 2: Get PS Version with Get-Variable PSVersionTable Command

You can also get your PS version using the command below:

powershell -command "(Get-Variable PSVersionTable -ValueOnly).PSVersion"

The result is the same as the last command

 

Method 3: Get PowerShell Version with Get-Host Command

Here is another command that will give your PS version

Get-Host

The command returned a result with the full version details

 

If you want just the version number, you can use any of the 3 commands below:

Get-Host | Select-Object Version

This command will expand the version numbers

Get-Host | Select-Object -ExpandProperty Version

(Get-Host).Version

The last two commands product the same result. Here are the results of the 3 commands

 

If you want to display just the Major PowerShell version, use this command:

(Get-Host).Version.Major

Method 4: Get Powershell Version with $Host Automatic Variable

To use this method type the following command into a PowerShell prompt. Then press Enter.

$Host

Below is the result of the command in PowerShell

 

As you can see, the result is the same as using the Get-Host Command

Here is an example:

 

Conclusion

There are so many reasons you may want to determine the PowerShell version. It may be that you wrote a script that requires a minimum version to run successfully. No matter your reason, I hope it met your need!

If you have any question or want to leave a comment, use the “Leave a Reply” form at the end of this script. Alternatively, you could share your experience working with PowerShell versions.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值