ps/Modules/Alkami.PowerShell.Common/Public/Get-OrbVersion.ps1

42 lines
1.1 KiB
PowerShell
Raw Permalink Normal View History

2023-05-30 22:51:22 -07:00
function Get-OrbVersion {
<#
.SYNOPSIS
Returns the version of orb, as read from the known version.txt file location.
.PARAMETER ComputerName
The computer name to retrieve the file from. If it is empty, will be the local machine.
.OUTPUTS
Can return null if the path can not be read
#>
[CmdletBinding()]
[OutputType([string])]
Param(
[Parameter(Mandatory = $false)]
[string]$ComputerName = "localhost"
)
$logLead = (Get-LogLeadName)
$versionPath = (Join-Path(Get-OrbPath) "WebClient/version.txt")
if (![string]::IsNullOrWhiteSpace($ComputerName)) {
if(!(Compare-StringToLocalMachineIdentifiers -StringToCheck $ComputerName)) {
$versionPath = (Get-UncPath -filePath $versionPath -ComputerName $ComputerName)
}
}
if(Test-Path $versionPath)
{
$versionTxt = (Get-Content $versionPath)
# this value is programmatically produced to always be
# the git hash of the branch being built, and the build number
# so we always can safely split on a space
$versionTxt = ($versionTxt.Split(" ")[1])
return $versionTxt
}
else
{
Write-Warning "$logLead - '$versionPath' was not found."
return $null
}
}