45 lines
1.3 KiB
PowerShell
45 lines
1.3 KiB
PowerShell
|
function Get-FileBeatsPath {
|
||
|
<#
|
||
|
.SYNOPSIS
|
||
|
Get the local installed folder path(s) for Filebeat.
|
||
|
#>
|
||
|
[CmdletBinding()]
|
||
|
[OutputType([string[]])]
|
||
|
param (
|
||
|
)
|
||
|
|
||
|
$logLead = (Get-LogLeadName)
|
||
|
|
||
|
# Define the known paths for easier validation
|
||
|
$deprecatedPath1 = "C:\Tools\Beats\FileBeat\filebeat-6.8.13-windows-x86_64"
|
||
|
$deprecatedPath2 = "C:\Tools\Beats\FileBeat\filebeat-6.1.2-windows-x86_64"
|
||
|
$expectedPath = "C:\Tools\Beats\FileBeat\tools"
|
||
|
$opensearchPath = "C:\Tools\Beats\FileBeat_os\tools"
|
||
|
|
||
|
# Should be installed in either the expectedPath or one of the deprecatedPaths
|
||
|
$possibleSearchLocations = @($expectedPath, $deprecatedPath1, $deprecatedPath2)
|
||
|
|
||
|
# We may have more than one instance of FileBeats installed on a given server
|
||
|
$returnPaths = @()
|
||
|
|
||
|
if (Test-Path $opensearchPath) {
|
||
|
$returnPaths += $opensearchPath
|
||
|
}
|
||
|
|
||
|
foreach ($path in $possibleSearchLocations) {
|
||
|
if (Test-Path $path) {
|
||
|
$returnPaths += $path
|
||
|
|
||
|
# Only take the first path found, if at all
|
||
|
break
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (Test-IsCollectionNullOrEmpty $returnPaths) {
|
||
|
Write-Warning "$logLead : Filebeats is not installed on $env:COMPUTERNAME"
|
||
|
# maintain legacy consistency by returning $null
|
||
|
$returnPaths = $null
|
||
|
}
|
||
|
|
||
|
return $returnPaths
|
||
|
}
|