ps/Modules/Alkami.PowerShell.Choco/Public/Test-IsEclairInstalled.ps1

47 lines
1.4 KiB
PowerShell
Raw Normal View History

2023-05-30 22:51:22 -07:00
function Test-IsEclairInstalled {
<#
.SYNOPSIS
Returns true if the Alkami Eclair package manager is installed and running correctly.
.DESCRIPTION
Eclair has the key "ALKAMI_ECLAIR" in the Description of the assembly. This can be found by
inspecting the VersionInfo object and getting the "Comments" field.
.PARAMETER ComputerName
Remote computer to inspct for Eclair installation. Uses UNC share.
#>
[CmdletBinding()]
[OutputType([System.Boolean])]
Param(
[Parameter(Mandatory = $false)]
[string]$ComputerName = "localhost"
)
$logLead = Get-logLeadName
$isEclairInstalled = $false
$chocoPath = (Get-Item (Join-Path (Get-ChocolateyInstallPath) 'choco.exe'))
if($ComputerName -ne "localhost") {
# Get the UNC path and find the file.
if($ComputerName -notlike "*.fh.local") {
$ComputerName = "$ComputerName.fh.local"
}
Write-Host "$logLead : Checking $computerName for choco.exe"
$chocoPath = Get-UncPath -ComputerName $ComputerName -filePath $chocoPath
}
Write-Host "$logLead : Checking path $chocoPath for VersionInfo."
$versionInfo = (Get-Item $chocoPath).VersionInfo
$versionInfoJson = $versionInfo | ConvertTo-Json -Depth 6
Write-Verbose "$logLead : $versionInfoJson"
if($versionInfo.Comments -like "ALKAMI_ECLAIR*") {
$isEclairInstalled = $true
}
return $isEclairInstalled
}