Compare-SemVerVersion
SYNOPSIS
Compares two versions and find whether they're equal, or one is newer than the other.
SYNTAX
Compare-SemVerVersion [-ReferenceVersion] <String> [[-DifferenceVersion] <String>] [<CommonParameters>]
DESCRIPTION
The Compare-SemVerVersion allows the comparison of SemVer 2.0 versions (including prerelease identifiers) as documented on semver.org The result will be = if the versions are equivalent, > if the reference version takes precedence, or \< if the difference version wins.
EXAMPLES
EXAMPLE 1
Compare-SemVerVersion -ReferenceVersion '0.2.3.546-alpha.201+01012018' -DifferenceVersion '0.2.3.546-alpha.200'
# >
Compare-SemVerVersion -ReferenceVersion '0.2.3.546-alpha.201+01012018' -DifferenceVersion '0.2.3.546-alpha.202'
# <
EXAMPLE 2
Compare-SemVerVersion -ReferenceVersion '0.2.3.546-alpha.201+01012018' -DifferenceVersion '0.2.3.546-alpha.201+01012015'
# =
PARAMETERS
-ReferenceVersion
The string version you would like to test.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-DifferenceVersion
The other string version you would like to compare agains the reference.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
INPUTS
OUTPUTS
System.String
NOTES
Worth noting that the documentaion of SemVer versions should follow this logic (from semver.org) 1.0.0-alpha \< 1.0.0-alpha.1 \< 1.0.0-alpha.beta \< 1.0.0-beta \< 1.0.0-beta.2 \< 1.0.0-beta.11 \< 1.0.0-rc.1 \< 1.0.0.