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!