How to determine PowerShell Version

I wanted to check my PowerShell version information. Perhaps I’ll need to do so in future scripts. Here’s how to determine the PowerShell Version from within PowerShell.

PS C:\Users\david.frette> $host.version

Major Minor Build Revision
—– —– —– ——–
2 0 -1 -1

PS C:\Users\david.frette> $host.version.major
2
PS C:\Users\david.frette> $host.version.minor
0
PS C:\Users\david.frette> $host.version.build
-1
PS C:\Users\david.frette> $host.version.revision
-1

Advertisements

4 responses to “How to determine PowerShell Version”

  1. Larry Weiss says :

    $host.version | select *

    will show all the fields:

    PS C:> $host.version | select *
    Major : 2
    Minor : 0
    Build : -1
    Revision : -1
    MajorRevision : -1
    MinorRevision : -1

  2. Richard Giles says :

    This is not a full proof way to get the version. Other products hosting the PowerShell automation engine may not have implemented the $host correctly. The correct way is to test for $PSVersionTable. If the variable is absent it is version 1.0.0.0. otherwise you can use that variable to get accurate information -> $psversiontable.psversion.

    See
    http://powershell.com/cs/blogs/tobias/archive/2010/01/24/are-you-using-the-correct-powershell-version.aspx

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: