This afternoon there was a discussion about determining the version of PowerShell installed on the local system. Each of us had our own answer. Someone mentioned the [System.Version] .Net class. Its a relatively small class that might you might find useful.
Lets take the Product Version of the PowerShell executable installed on my Windows 7 workstation and get the properties of the class.
$Version = [Version][Diagnostics.FileVersionInfo]::GetVersionInfo(
$Version | Select *
And this is what we get:
Major : 6
Minor : 1
Build : 7100
Revision : 0
MajorRevision : 0
MinorRevision : 0
System.Version also implements operators so you can use the PowerShell comparison operators. For example lets say you want to compare the current version of PowerShell to determine if its a later release the CTP3. Just using the following statement.
$Version -gt [System.Version]"6.1.6949.0"