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) -eq $null)
{
new-Object system.Version "1.0.0.0"
}
else
{
$psversiontable.psversion
}
}
-Karl
Posted
Jun 04 2008, 09:07 PM
by
Karl Prosser