Last active
March 1, 2017 16:57
-
-
Save pinecones-sx/9749b370594eea2254d5fb6eb3cc1caf to your computer and use it in GitHub Desktop.
fixed nested if
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-VersionAsInt { | |
param($VersionInfo,[switch]$FileVersion) | |
$digits = 6 | |
If ($FileVersion){$iVersionNumber = $VersionInfo.FileVersion} | |
Else{$iVersionNumber = $VersionInfo.ProductVersion} | |
$rVersionInt = '' | |
ForEach ($versionPart in ($iVersionNumber -split '\.')){ | |
$lessDigits = $digits - $versionPart.Length | |
For ($i = 0 ; $i -lt $lessDigits ; $i++){ | |
$versionPart = '0' + $versionPart | |
} | |
$rVersionInt = $rVersionInt + [string]$versionPart | |
} | |
$rVersionInt = [decimal]($rVersionInt.TrimStart('0')) | |
Return $rVersionInt | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment