Quantcast
Channel: Active questions tagged powershell-3.0 - Stack Overflow
Viewing all articles
Browse latest Browse all 123

How to verify version format in powershell script?

$
0
0

So I am trying to verify if a provided version number is valid or not in powershell with the following code:

$ParsedVersion=''if ([System.Version]::TryParse("1.2.3.43", [ref]$ParsedVersion)) {    Write-Host ("valid version")}else {    Write-Host ("invalid version")}

but I keep getting the error Exception calling "TryParse" with "2" argument(s): "Cannot convert value "" to type "System.Version". Error: "Versionstring portion was too short or too long.""

I tried lots of different ways but still no luck. I am wondering if there exists a right way to do this? Appreciate your help!


Viewing all articles
Browse latest Browse all 123

Trending Articles