Jun
3
Written by:
Karl Prosser
6/3/2008 10:40 PM
Many people recently have asked how to determine programatically what version of PowerShell their script is running in. Well in version two there is a $psversiontable variable, but this sadly isn't in V1. All is not lost though, as you can write a simple function to return a version object for v1. Below is a quick function that I wrote that I have been using for the last year or so.
function get-psVersion
{
if ((get-Variable psversiontabl[e]) -eq $null)
{
new-Object system.Version "1.0.0.0"
}
else
{
$psversiontable.psversion
}
}
-Karl
Tags: