Misc/Get-NormalizedVersion.ps1

<#
.SYNOPSIS
Normalizes Version to be able to use it with DevOps
.DESCRIPTION
Normalizes Version to be able to use it with DevOps. This means that revisions can't be added, therefore, it will be done as a pre-release
.PARAMETER version
Version to be normalized
.EXAMPLE
$newVersion = Get-NormalizedVersion -version '1.2.3.4'
#>

function Get-NormalizedVersion {
    Param(
        [Parameter(Mandatory=$true)]
        [string]$version
    )

    if ($version -ne "" -and -not $version.Contains("-")) {
        $tempVersion = "{0}.{1}.{2}" -f ([version]$version).Major, ([version]$version).Minor, ([version]$version).Build
        if (([version]$version).Revision -ne "0" -and ([version]$version).Revision -ne "-1") {
            $tempVersion = "{0}-{1}" -f $tempVersion, ([version]$version).Revision
        }
        $version = $tempVersion
    }
    else {
        if ($version -eq "") {
            $version = "*"
        }
    }

    $version
}