确定已安装的 PowerShell 版本 [英] Determine installed PowerShell version

查看:59
本文介绍了确定已安装的 PowerShell 版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何确定计算机上安装了哪个版本的 PowerShell,以及是否安装了它?

How can I determine what version of PowerShell is installed on a computer, and indeed if it is installed at all?

推荐答案

使用 $PSVersionTable.PSVersion 来确定引擎版本.如果该变量不存在,则可以安全地假设引擎版本为 1.0.

Use $PSVersionTable.PSVersion to determine the engine version. If the variable does not exist, it is safe to assume the engine is version 1.0.

请注意,$Host.Version(Get-Host).Version 不可靠 - 它们反映了仅主机版本,而不是引擎.电源GUI,PowerShellPLUS 等都是托管应用程序,并且他们将设置主机的版本以反映他们的产品版本 —这是完全正确的,但不是您要查找的内容.

Note that $Host.Version and (Get-Host).Version are not reliable - they reflect the version of the host only, not the engine. PowerGUI, PowerShellPLUS, etc. are all hosting applications, and they will set the host's version to reflect their product version — which is entirely correct, but not what you're looking for.

PS C:\> $PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
4      0      -1     -1

这篇关于确定已安装的 PowerShell 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆