diff --git a/Functions/Public/Invoke-GraylogRequest.ps1 b/Functions/Public/Invoke-GraylogRequest.ps1 index b5a558f..058dfcf 100644 --- a/Functions/Public/Invoke-GraylogRequest.ps1 +++ b/Functions/Public/Invoke-GraylogRequest.ps1 @@ -49,6 +49,7 @@ function Invoke-GraylogRequest { [string] $ContentType = "application/json" ) + if (-NOT (Test-GraylogSession -SkipSessionCheck)) { return } # Ensure that the Secrets are set $Session = Get-Secret Graylog_Session -Vault Graylog -AsPlainText -ErrorAction Stop $Request = @{ Method = $Method @@ -57,5 +58,6 @@ function Invoke-GraylogRequest { ContentType = $ContentType } if ($Body) { $Request.Body = $Body } - Invoke-RestMethod @Request + try { Invoke-RestMethod @Request } + catch { throw $_.Exception.Message } } \ No newline at end of file