I have multiple computer systems at home. I have previously taken a picture of my home office and published it here. Also, I recently had a scenario where I was listing a PowerShell version installed in my computer systems. While searching online, I found two different commands that can determine the version of PowerShell. One of them worked fine in Version 1, while both worked on Version 2.
The commands are:
$PSVersionTable
and
$host
I have run both the commands on different PowerShell versions and found the following output. This is a call to all PowerShell experts to help me out by letting me know the reasons why these became the results. I am sure that I’m missing something very small, so I ask your help to clarify this.
PowerShell Version 1
PowerShell Version 2
Reference : Pinal Dave (https://blog.sqlauthority.com)
2 Comments. Leave new
Hi,
You could try this.
if (Test-Path Variable:PSVersionTable) {$PSVersionTable.PSVersion} else {[Version]”1.0.0.0″}
$PSVersionTable exists only in PowerShell version 2 IIRC.
Also:
(Get-Item HKLM:\Software\Microsoft\PowerShell\1\PowerShellEngine).GetValue(“RuntimeVersion”)