42 lines
1.1 KiB
PowerShell
42 lines
1.1 KiB
PowerShell
|
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
|
||
|
}
|
||
|
}
|