Tip of the Day: Windows PowerShell Versions


Today’s Tip…

Windows PowerShell has been out for a few versions now.  The following Windows versions had different versions of PowerShell.

 

  • Windows Server 2008 – PowerShell 1.0 (optional component)
  • Windows 7/Windows Server 2008 R2 – PowerShell 2.0
  • Windows 8/Windows Server 2012 – PowerShell 3.0
  • Windows8.1/Windows Server 2012 R2 – PowerShell 4.0

Also, PowerShell could be downloaded separately and installed in some downlevel versions of Windows.

An easy way to find out what version of PowerShell you are using is to use the Get-Host cmdlet.

image

Additionally, you can utilize the $PSVersionTable variable.

SNAGHTML47bef519

If you’re using this as a determining factor in an application, you can use the pre-populated $host variable, and then dot your way to see the major/minor version, like:

$host.version.major

$host.version.minor


Comments (1)

  1. Anonymous says:

    I worry about teaching people to use Get-Host, or $Host, as a way to determine the installed version of PowerShell. If someone that uses Get-Host, or $Host, runs Enter-PSSession on a 2012/2012 R2 server, for example, and enters $Host.Version.Major, they
    will end up having to determine why it’s reporting version 1, when it should be returning version 4 ($PSVersionTable.PSVersion.Major).

    Get-Host, or $Host, reports on the version of the host, and not the version of PowerShell, even though those are often the same. Even the help for Get-Host indicates it returns an object that is *hosting* Windows PowerShell.

Skip to main content