Different ways to find Powershell Version

  • Comments posted to this topic are about the item Different ways to find Powershell Version

    Thanks.

  • Why I am getting this ?

    PS SQLSERVER:\SQL\USER-PC\EXPRESS_ADV_2014>

    PS SQLSERVER:\SQL\USER-PC\EXPRESS_ADV_2014> (Get-Host).Version

    Major Minor Build Revision

    ----- ----- ----- --------

    2 0 -1 -1

    PS SQLSERVER:\SQL\USER-PC\EXPRESS_ADV_2014>

    I am using rarely PowerShell and sqlps but it is one of the rare commands I know ( I prefer to use SSMS or SMO applications but it is only a question of taste ).

    I think that I was not able to find the good choice because my lack of habit to use sqlps...

  • I did not understand what was meant by '(through queries)'. When I execute $PSVersionTable.PSVersion in Powershell I get the barely informative

    Major Minor Build Revision

    ----- ----- ----- --------

    2 0 -1 -1

    However, if I leave off the PSVersion, which is what is used in the answer link, I get something that seems more helpful:

    PS H:\> $PSVersionTable

    Name Value

    ---- -----

    CLRVersion 2.0.50727.5483

    BuildVersion 6.1.7601.17514

    PSVersion 2.0

    WSManStackVersion 2.0

    PSCompatibleVersions {1.0, 2.0}

    SerializationVersion 1.1.0.1

    PSRemotingProtocolVersion 2.1

    So I'm not sure a correct answer was really listed. Also, $host.version and (Get-Host).Version give the same result as $PSVersionTable.PSVersion so picked the shortest string to get the result.

  • +1

    But I think that the question would have included checkbox and not radiobutton ( which are exclusive )

  • I don't use Powershell, so this was a complete guess for me.

  • In the version of powershell2.0 $Host.version also works

    It returns:

    Major Minor Build Revision

    ----- ----- ----- --------

    2 0 -1 -1

    same as does $Powershell.version

  • This was removed by the editor as SPAM

  • patricklambin (3/27/2015)


    Why I am getting this ?

    PS SQLSERVER:\SQL\USER-PC\EXPRESS_ADV_2014>

    PS SQLSERVER:\SQL\USER-PC\EXPRESS_ADV_2014> (Get-Host).Version

    Major Minor Build Revision

    ----- ----- ----- --------

    2 0 -1 -1

    PS SQLSERVER:\SQL\USER-PC\EXPRESS_ADV_2014>

    I am using rarely PowerShell and sqlps but it is one of the rare commands I know ( I prefer to use SSMS or SMO applications but it is only a question of taste ).

    I think that I was not able to find the good choice because my lack of habit to use sqlps...

    This seems to work, but it returns the version of the host, not of PoSh installed. If you have an older version of the PosH shell or ISE, you'll get that, instead of the version of PoSh available on the machine.

  • Good question.

    In both versions I've had (2.0,4.0) the returns from (Get-Host).Version, $psversiontable.PSVersion, and $Host.Version have been identical - so perhaps from version 2.0 onwards the powershell version and the ConsoleHost versions have stayed in step. I wonder if that's deliberate and will continue to be true?

    Anyway, I got it wrong because I thought they both meant the same. Using $psversiontable and $host instead of the two level things delivers much more information, and was a revelation to me today when I discovered it from one of the comments on this question, so I've learnt something potentially useful today. But I don't like the answer to the question, since it gives me "build -1" instead of a real build version and doesn't tell me which version of the remoting protocol it uses or the versions of other interesting things the way the shorter version does.

    Tom

  • Ed Wagner (3/27/2015)


    I don't use Powershell, so this was a complete guess for me.

    Same 🙂

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

  • Options 2,3,4 gave the exact same result!

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

  • Nice question, thanks.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Thanks for the question.

Viewing 13 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic. Login to reply