Private/Test-SIASession.ps1
|
function Test-SIASession { <# Confirms an active, unexpired psSIA session exists. Every public cmdlet that calls the API funnels through this before Invoke-SIARequest builds a request, so there is one place that defines what "logged in" means. #> [CmdletBinding()] [OutputType([pscustomobject])] param( [switch]$PassThru ) if (-not $script:SIASession) { throw 'No active SIA session. Run New-SIASession first.' } if ((Get-Date).ToUniversalTime() -ge $script:SIASession.ExpiresAt) { throw 'The SIA session token has expired. Run New-SIASession again.' } if ($PassThru) { $script:SIASession } } |