Functions/Get-GraylogSidecarNodeId.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
<#
    .SYNOPSIS
        Get the current sidecar node id.
 
    .DESCRIPTION
        Read the node-id file to get the current id of the sidecar node.
 
    .EXAMPLE
        PS C:\> Get-GraylogSidecarNodeId
        Get the current sidecar node id.
#>

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

    try
    {
        $nodeId = Get-Content -Path 'C:\Program Files\Graylog\sidecar\node-id' -Raw -ErrorAction 'Stop'
        $nodeId = $nodeId.Trim()
        return $nodeId
    }
    catch
    {
        return ''
    }
}