public/Session/Get-Session.ps1

using namespace System.Management.Automation
using module '..\..\modules\Enums.psm1'
using module '..\..\modules\Helper\DateTimeHelper.psm1'
using module '..\..\modules\Session.psd1'

function Get-Session{
    [CmdletBinding()]
    [Alias('gs')]
    param(
        [int] $sessionId=-1,
        [switch] $reimport
    )

    if ($sessionId -eq -1){
        if ([Session]::activeSessions.Count -gt 0){
            Write-Output ([Session]::AllSessionInfo())
        }
        else {
            Write-Host 'There is no active session.'
        }
    }
    else {
        $session = [Session]::getSession($sessionId)
        if ($session){
            [Session]::currentSessionId = $sessionId

            if ($reimport){
                $params = @{}
                $params.Add('AsJob', $session.IsAsync())
                $params.Add('operator', $session.Operator)
                $params.Add('environment', $session.Environment)
                $params.Add('source', $session.config.sources)

                $params.Add('operator', $session.Operator)

                switch ($session.queryType) {
                    ([QUERY_TYPE]::matchId) {
                        $params.Add('matchId', $session.matchId)
                    }
                    ([QUERY_TYPE]::datetimeInterval) {
                        Write-Error "Search without matchId is not allowed"
                        return

                        $params.Add('matchId', $session.matchId)
                        $params.Add('referentTime', $session.config.referentTime)
                        $params.Add('timeSpan', $session.config.timeSpan)
                    }
                    ([QUERY_TYPE]::combined) {
                        $params.Add('matchId', $session.matchId)
                        $params.Add('referentTime', $session.config.referentTime)
                        $params.Add('timeSpan', $session.config.timeSpan)
                    }
                }
                Import-AuditLogs @params
            }
            else {
                Write-Output ($session.SessionInfo() | Format-Table)
            }
        }
    }
}