SQL SERVER – PowerShell Version Info

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:




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

SQL SERVER – PowerShell Version Info powershell1

PowerShell Version 2

SQL SERVER – PowerShell Version Info powershell2

Reference : Pinal Dave (https://blog.sqlauthority.com)

Powershell, SQL Scripts
Previous Post
SQL SERVER – Index Levels, Page Count, Record Count and DMV – sys.dm_db_index_physical_stats
Next Post
SQLAuthority News – I am Microsoft Certified Trainer (MCT)

Related Posts

2 Comments. Leave new

  • Marko Parkkola
    July 5, 2010 1:18 pm


    You could try this.

    if (Test-Path Variable:PSVersionTable) {$PSVersionTable.PSVersion} else {[Version]”″}

    $PSVersionTable exists only in PowerShell version 2 IIRC.

  • Also:
    (Get-Item HKLM:\Software\Microsoft\PowerShell\1\PowerShellEngine).GetValue(“RuntimeVersion”)


Leave a Reply