functions/secret-access-requests/Get-TssSecretAccessRequestSecret.ps1
function Get-TssSecretAccessRequestSecret { <# .SYNOPSIS Get Secret Access Request by Secret ID for Current User .DESCRIPTION Get Secret Access Request by Secret ID for Current User .EXAMPLE $session = New-TssSession -SecretServer https://alpha -Credential $ssCred Get-TssSecretAccessRequestSecret -TssSession $session -SecretId 42 Get any Secret Access Request on Secret 42 for current user (based on access token for session) .LINK https://thycotic-ps.github.io/thycotic.secretserver/commands/Get-TssSecretAccessRequestSecret .LINK https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/secret-access-requests/Get-TssSecretAccessRequestSecret.ps1 .NOTES Requires TssSession object returned by New-TssSession #> [CmdletBinding()] [OutputType('Thycotic.PowerShell.AccessRequests.Request')] param ( # TssSession object created by New-TssSession for authentication [Parameter(Mandatory,ValueFromPipeline,Position = 0)] [Thycotic.PowerShell.Authentication.Session] $TssSession, # Short description for parameter [Parameter(Mandatory,ValueFromPipelineByPropertyName)] [Alias("Id")] [int[]] $SecretId ) begin { $tssParams = $PSBoundParameters $invokeParams = . $GetInvokeApiParams $TssSession } process { Write-Verbose "Provided command parameters: $(. $GetInvocation $PSCmdlet.MyInvocation)" if ($tssParams.ContainsKey('TssSession') -and $TssSession.IsValidSession()) { . $CheckVersion $TssSession '10.9.000000' $PSCmdlet.MyInvocation foreach ($secret in $SecretId) { $restResponse = $null $uri = $TssSession.ApiUrl, 'secret-access-requests', 'secrets', $secret -join '/' $invokeParams.Uri = $uri $invokeParams.Method = 'GET' Write-Verbose "Performing the operation $($invokeParams.Method) $uri with $body" try { $apiResponse = Invoke-TssApi @invokeParams $restResponse = . $ProcessResponse $apiResponse } catch { Write-Warning "Issue getting access request on Secret [$secret]" $err = $_ . $ErrorHandling $err } if ($restResponse.records) { [Thycotic.PowerShell.AccessRequests.Request[]]$restResponse.records } } } else { Write-Warning "No valid session found" } } } |