Private/UpgradeInitializationScriptHelperFunctions.ps1
function Test-Version { Param ( [Parameter(Mandatory=$true)] [string] $version ) $type = "OnPrem" $fullVersionNo = $false $ok = $false if ($version.indexOf('.') -eq -1) { $verno = 0 $ok = [int32]::TryParse($version, [ref]$verno) if (!$ok) { Write-Host -ForegroundColor Red "Illegal version number. Run New-UpgradeInitizalitionScript without parameters instead." } } else { $verno = [Version]"0.0.0.0" $ok = [Version]::TryParse($version, [ref]$verno) if (!$ok) { Write-Host -ForegroundColor Red "Illegal version number. Run New-UpgradeInitizalitionScript without parameters instead." } $fullVersionNo = $verno.Revision -ne -1 } if ($ok) { if ($fullVersionNo) { $select = "Closest" $artifactUrl = Get-BCArtifactUrl -type $type -version $version -country 'w1' -select 'Closest' if ($artifactUrl) { $foundVersion = $artifactUrl.split('/')[4] if ($foundVersion -ne $version) { Write-Host -ForegroundColor Yellow "The specific version doesn't exist, closest version is $foundVersion" } } } else { $versions = @() Get-BCArtifactUrl -type $type -version $version -country 'w1' -select All | ForEach-Object { $versions += $_.Split('/')[4] } if ($versions.Count -eq 0) { Write-Host -ForegroundColor Red "Unable to find a version matching the specified version" $ok = $false } elseif ($versions.Count -gt 1) { Write-Host -ForegroundColor Red "More than one version found. Enter a specific version or run New-UpgradeInitizalitionScript without parameters instead." $ok = $false } } } Write-Output $ok } function Get-FullVersion { Param ( [Parameter(Mandatory=$true)] [string] $version ) $type = "OnPrem" $fullVersionNo = $false $ok = $false if ($version.indexOf('.') -eq -1) { $verno = 0 $ok = [int32]::TryParse($version, [ref]$verno) if (!$ok) { Write-Host -ForegroundColor Red "Illegal version number. Run New-UpgradeInitizalitionScript without parameters instead." } } else { $verno = [Version]"0.0.0.0" $ok = [Version]::TryParse($version, [ref]$verno) if (!$ok) { Write-Host -ForegroundColor Red "Illegal version number. Run New-UpgradeInitizalitionScript without parameters instead." } $fullVersionNo = $verno.Revision -ne -1 } if ($ok) { if ($fullVersionNo) { $select = "Closest" $artifactUrl = Get-BCArtifactUrl -type $type -version $version -country 'w1' -select 'Closest' if ($artifactUrl) { $foundVersion = $artifactUrl.split('/')[4] if ($foundVersion -ne $version) { Write-Host -ForegroundColor Yellow "The specific version doesn't exist, closest version is $foundVersion. Enter a specific version or run New-UpgradeInitizalitionScript without parameters instead." } } } else { $versions = @() Get-BCArtifactUrl -type $type -version $version -country 'w1' -select All | ForEach-Object { $versions += $_.Split('/')[4] } if ($versions.Count -eq 0) { Write-Host -ForegroundColor Red "Unable to find a version matching the specified version" $ok = $false } elseif ($versions.Count -gt 1) { Write-Host -ForegroundColor Red "More than one version found. Enter a specific version or run New-UpgradeInitizalitionScript without parameters instead." $ok = $false } } } if ($ok) { Write-Output $versions[0] } } |