Functions/Get-GraylogSidecarVersion.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<#
    .SYNOPSIS
        Get the installed Graylog Sidecar version.
 
    .DESCRIPTION
        Scan the MSI Uninstall registry key to detect, if the Graylog Sidecar is
        installed. Return the installed version or an empty string, if not
        installed.
 
    .EXAMPLE
        PS C:\> Get-GraylogSidecarVersion
        This will return the current intalled version.
#>

function Get-GraylogSidecarVersion
{
    [CmdletBinding()]
    [OutputType([System.String])]
    param ()

    try
    {
        $displayVersion = Get-ItemPropertyValue -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\GraylogSidecar' -Name 'DisplayVersion' -ErrorAction Stop

        Write-Verbose "Graylog Sidecar Version = $displayVersion"

        return $displayVersion
    }
    catch
    {
        Write-Verbose 'Graylog Sidecar Version does not exist'

        return ''
    }
}