functions/external-vaults/Get-TssExternalVaultMetric.ps1
|
function Get-TssExternalVaultMetric { <# .SYNOPSIS Get metrics for an external vault .DESCRIPTION Get metrics for an external vault: the total number of external vault secrets linked to it. The count includes every external vault secret linked to the vault, including ones the caller cannot see. .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-TssExternalVaultMetric -TssSession $session -Id 3 Get the metrics for external vault 3 .LINK https://thycotic-ps.github.io/thycotic.secretserver/commands/external-vaults/Get-TssExternalVaultMetric .LINK https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/external-vaults/Get-TssExternalVaultMetric.ps1 .NOTES Requires TssSession object returned by New-TssSession #> [CmdletBinding()] [OutputType('Thycotic.PowerShell.ExternalVaults.Metric')] 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, 'metrics' -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-TssExternalVaultMetric request' $err = $_ . $ErrorHandling $err } if ($restResponse) { [Thycotic.PowerShell.ExternalVaults.Metric](. $FilterTssResponse $restResponse ([Thycotic.PowerShell.ExternalVaults.Metric])) } } } else { Write-Warning 'No valid session found' } } } |