How can I determine what version of PowerShell is installed on a computer, and indeed if it is installed at all?
标签:
powershell
相关问题
- How to Debug/Register a Permanent WMI Event Which
- How can I do variable substitution in a here-strin
- How to use a default value with parameter sets in
- Does powershell have a method_missing()?
- Invoking Mirth Connect CLI with Powershell script
相关文章
- 在vscode如何用code runner打开独立的控制台窗口,以及设置好调试模式时窗口的编码?
- C#调用PowerShell的问题
- EscapeDataString having differing behaviour betwee
- PowerShell Change owner of files and folders
- Command line escaping single quote for PowerShell
- Is there a simple way to pass specific *named* Pow
- How do I access an element with xpath with a names
- How to 'Grant Permissions' Using Azure Act
Use
$PSVersionTable.PSVersion
to determine the engine version. If the variable does not exist, it is safe to assume the engine is version1.0
.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.Use:
You can download the detailed script from How to determine installed PowerShell version.
Use the Get-Host command. The second line of the result is the version.
Just want to add my 2 cents here.
You can directly check the version with one line only by invoking powershell externally, such as from Command Prompt
EDIT:
According to @psaul you can actually have one command that is agnostic from where it came (CMD, Powershell or Pwsh), thank you for that.
I've tested and it worked flawlessly on both CMD and Powershell
Try it with following command:
Seen here
The easiest way to forget this page and never return to it is to learn the
Get-Variable
:There is no need to remember every variable. Just
Get-Variable
is enough (and "There should be something about version").