PSGraylog/Functions/Disconnect-GraylogService.ps1
2024-07-25 02:31:34 +01:00

27 lines
796 B
PowerShell

function Disconnect-GraylogService {
<#
.SYNOPSIS
Disconnects from the Graylog server.
.DESCRIPTION
Disconnects from the Graylog server by deleting the session using the current WebSession data. By default, the stored credentials are not removed.
.PARAMETER Force
An optional switch to force the removal of the stored credentials as well as the session.
.OUTPUTS
None
.EXAMPLE
Disconnect-GraylogService
Disconnects from the Graylog server.
.NOTES
Garbage collection is called after the session is deleted to ensure that the session is removed from memory.
#>
[Alias("Disconnect-Graylog")]
param (
[Parameter()]
[Switch]
$Force
)
Invoke-GraylogRequest DELETE "/api/system/sessions"
Remove-Secret Graylog_Session
if ($Force) { Remove-Secret Graylog_Credential }
}