Determining what version of PowerShell your script is running in.
June 4th, 2008 by KarlMany 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
Posted in Powershell |

Entire RSS