Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Get-Host

$
0
0

Thank you!

So Get-Host will usually return the right value, but might be wrong in some Special cases.
$psversiontable will fail on Powershell V1 but I found a great Workaround:


# If the $PSVersionTable variable doesn't exist, then you are running V1.
# If it does exist, then the version will be available as $PSVersionTable.PSVersion.

function Get-PSVersion {
if (test-path variable:psversiontable) {$psversiontable.psversion} else {[version]"1.0.0.0"}
}

Source: http://powershell.com/cs/media/p/2617.aspx

In the end I decided to avoid getting and processing the version info and inserted a “#Requires -version 3.0″ statement instead.


Viewing all articles
Browse latest Browse all 13067

Trending Articles