functions/sdk-client-rules/Get-TssSdkClientRule.ps1
|
function Get-TssSdkClientRule { <# .SYNOPSIS Get an SDK client rule by ID .DESCRIPTION Get one or more SDK client rules by ID. An ID with no matching SDK client rule writes an error. .PARAMETER TssSession TssSession object created by New-TssSession for authentication .PARAMETER Id SDK client rule ID .EXAMPLE $session = New-TssSession -SecretServer https://alpha -Credential $ssCred Get-TssSdkClientRule -TssSession $session -Id 3 Returns SDK client rule 3 .LINK https://thycotic-ps.github.io/thycotic.secretserver/commands/sdk-client-rules/Get-TssSdkClientRule .LINK https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/sdk-client-rules/Get-TssSdkClientRule.ps1 .NOTES Requires TssSession object returned by New-TssSession #> [CmdletBinding()] [OutputType('Thycotic.PowerShell.SdkClientRules.SdkClientRule')] param ( [Parameter(Mandatory, ValueFromPipeline, Position = 0)] [Thycotic.PowerShell.Authentication.Session] $TssSession, [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [int[]] $Id ) 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 foreach ($currentId in $Id) { $restResponse = $null $uri = $TssSession.ApiUrl, 'sdk-client-rules', $currentId -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 Get-TssSdkClientRule request' $err = $_ . $ErrorHandling $err } if ($restResponse -eq 'null') { $PSCmdlet.WriteError([Management.Automation.ErrorRecord]::new([Exception]::new("SDK client rule $currentId not found"), 'SdkClientRuleNotFound', 'ObjectNotFound', $currentId)) } elseif ($restResponse) { [Thycotic.PowerShell.SdkClientRules.SdkClientRule](. $FilterTssResponse $restResponse ([Thycotic.PowerShell.SdkClientRules.SdkClientRule])) } } } else { Write-Warning 'No valid session found' } } } |