functions/external-vaults/Get-TssExternalVault.ps1
|
function Get-TssExternalVault { <# .SYNOPSIS Get an external vault .DESCRIPTION Gets an external vault link (Azure Key Vault, AWS Secrets Manager, Google Secret Manager or HashiCorp Vault): its type, credential secret, distributed engine site, secret name filter, last pull date and the permissions of the current user. .PARAMETER TssSession TssSession object created by New-TssSession for authentication .PARAMETER Id External vault id .EXAMPLE $session = New-TssSession -SecretServer https://alpha -Credential $ssCred Get-TssExternalVault -TssSession $session -Id 2 Get external vault 2 .EXAMPLE $session = New-TssSession -SecretServer https://alpha -Credential $ssCred Search-TssExternalVault -TssSession $session -ExternalVaultType HashiCorpVault | Get-TssExternalVault -TssSession $session Get every active HashiCorp Vault link .LINK https://thycotic-ps.github.io/thycotic.secretserver/commands/external-vaults/Get-TssExternalVault .LINK https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/external-vaults/Get-TssExternalVault.ps1 .NOTES Requires TssSession object returned by New-TssSession #> [CmdletBinding()] [OutputType('Thycotic.PowerShell.ExternalVaults.ExternalVault')] param ( [Parameter(Mandatory, ValueFromPipeline, Position = 0)] [Thycotic.PowerShell.Authentication.Session] $TssSession, [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [Alias('ExternalVaultId')] [int[]] $Id ) begin { $tssParams = $PSBoundParameters $invokeParams = . $GetInvokeApiParams $TssSession } process { Get-TssInvocation $PSCmdlet.MyInvocation if ($tssParams.ContainsKey('TssSession') -and $TssSession.IsValidSession()) { Compare-TssVersion $TssSession '11.7.000000' $PSCmdlet.MyInvocation foreach ($currentId in $Id) { $restResponse = $null $uri = $TssSession.ApiUrl, 'external-vaults', 'vaults', $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-TssExternalVault request' $err = $_ . $ErrorHandling $err } if ($restResponse) { [Thycotic.PowerShell.ExternalVaults.ExternalVault](. $FilterTssResponse $restResponse ([Thycotic.PowerShell.ExternalVaults.ExternalVault])) } } } else { Write-Warning 'No valid session found' } } } |