functions/secrets/Search-TssSecretLauncherSession.ps1
|
function Search-TssSecretLauncherSession { <# .SYNOPSIS Search active secret launcher sessions .DESCRIPTION Search the active launcher sessions of one secret. .PARAMETER TssSession TssSession object created by New-TssSession for authentication .PARAMETER SecretId Secret Id whose active launcher sessions to return. Required: Secret Server returns no sessions without it .EXAMPLE $session = New-TssSession -SecretServer https://alpha -Credential $ssCred Search-TssSecretLauncherSession -TssSession $session -SecretId 42 Get the active launcher sessions of secret 42 .LINK https://thycotic-ps.github.io/thycotic.secretserver/commands/secrets/Search-TssSecretLauncherSession .LINK https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/secrets/Search-TssSecretLauncherSession.ps1 .NOTES Requires TssSession object returned by New-TssSession #> [CmdletBinding()] [OutputType('Thycotic.PowerShell.Secrets.LauncherSession[]')] param ( [Parameter(Mandatory, ValueFromPipeline, Position = 0)] [Thycotic.PowerShell.Authentication.Session] $TssSession, [Parameter(Mandatory)] [int] $SecretId ) begin { $tssParams = $PSBoundParameters $invokeParams = . $GetInvokeApiParams $TssSession } process { Get-TssInvocation $PSCmdlet.MyInvocation if ($tssParams.ContainsKey('TssSession') -and $TssSession.IsValidSession()) { Compare-TssVersion $TssSession '10.9.000000' $PSCmdlet.MyInvocation $uri = $TssSession.ApiUrl, 'secrets', 'launcher-sessions' -join '/' $queryParams = @() $queryParams += "take=$($TssSession.Take)" switch ($tssParams.Keys) { 'SecretId' { $queryParams += "filter.secretId=$($SecretId)" } } if ($queryParams) { $uri = $uri, ($queryParams -join '&') -join '?' } $invokeParams.Uri = $uri $invokeParams.Method = 'GET' Write-Verbose "Performing the operation $($invokeParams.Method) $uri" try { $apiResponse = Invoke-TssApi @invokeParams $restResponse = . $ProcessResponse $apiResponse } catch { Write-Warning 'Issue with Search-TssSecretLauncherSession request' $err = $_ . $ErrorHandling $err } if ($restResponse.records) { [Thycotic.PowerShell.Secrets.LauncherSession[]](. $FilterTssResponse $restResponse.records ([Thycotic.PowerShell.Secrets.LauncherSession])) } } else { Write-Warning 'No valid session found' } } } |