PSGraylog/Functions/Public/Get-GraylogStreamId.ps1

25 lines
813 B
PowerShell
Raw Normal View History

2024-07-25 02:31:34 +01:00
function Get-GraylogStreamId {
<#
.SYNOPSIS
Gets the ID of a log stream in Graylog.
.DESCRIPTION
Gets the ID of a log stream in Graylog using the provided log name.
.PARAMETER LogName
The name of the log stream to get the ID for, the log name has to be an exact match for a known log stream.
.OUTPUTS
The ID of the log stream if it exists, otherwise null.
.EXAMPLE
Get-GraylogStreamId -LogName "Windows Security"
Gets the ID of the log stream with the name "Windows Security" (645b6fdd9d3689589cdce1bc).
#>
param (
[Parameter(Mandatory)]
[ValidateSet("Infoblox", "Infoblox DNS", "Windows Application", "Windows Security", "Windows System")]
[string]
$LogName
)
$Stream = (Get-GraylogStreams).Where{$_.Title -eq $LogName}
2024-07-25 02:31:34 +01:00
if ($null -eq $Stream) { return $null }
return $Stream.Id
}