functions/event-subscriptions/Search-TssEventSubscription.ps1
|
function Search-TssEventSubscription { <# .SYNOPSIS Search event subscriptions .DESCRIPTION Search event subscriptions. Returns the ID, name and active state of each; use Get-TssEventSubscription for entity actions and subscribers. .PARAMETER TssSession TssSession object created by New-TssSession for authentication .PARAMETER IncludeInactive Include inactive event subscriptions .EXAMPLE $session = New-TssSession -SecretServer https://alpha -Credential $ssCred Search-TssEventSubscription -TssSession $session -IncludeInactive Return all event subscriptions, active and inactive .LINK https://thycotic-ps.github.io/thycotic.secretserver/commands/event-subscriptions/Search-TssEventSubscription .LINK https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/event-subscriptions/Search-TssEventSubscription.ps1 .NOTES Requires TssSession object returned by New-TssSession #> [CmdletBinding()] [OutputType('Thycotic.PowerShell.EventSubscriptions.EventSubscriptionItem[]')] param ( [Parameter(Mandatory, ValueFromPipeline, Position = 0)] [Thycotic.PowerShell.Authentication.Session] $TssSession, [switch] $IncludeInactive ) 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, 'event-subscriptions' -join '/' $queryParams = @() $queryParams += "take=$($TssSession.Take)" switch ($tssParams.Keys) { 'IncludeInactive' { $queryParams += "filter.includeInactive=$([boolean]$IncludeInactive)" } } 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-TssEventSubscription request' $err = $_ . $ErrorHandling $err } if ($restResponse.records) { [Thycotic.PowerShell.EventSubscriptions.EventSubscriptionItem[]](. $FilterTssResponse $restResponse.records ([Thycotic.PowerShell.EventSubscriptions.EventSubscriptionItem])) } } else { Write-Warning 'No valid session found' } } } |