functions/remote-password-changing/Get-TssRpcPasswordType.ps1
|
function Get-TssRpcPasswordType { <# .SYNOPSIS Get Password Type .DESCRIPTION Get Password Type .EXAMPLE $session = New-TssSession -SecretServer https://alpha -Credential $ssCred Get-TssRpcPasswordType -TssSession $session -Id 52 Get Password Type 52 .LINK https://thycotic-ps.github.io/thycotic.secretserver/commands/rpc/Get-TssRpcPasswordType .LINK https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/rpc/Get-TssRpcPasswordType.ps1 .NOTES Requires TssSession object returned by New-TssSession #> [CmdletBinding()] [OutputType('Thycotic.PowerShell.Rpc.PasswordType')] param ( # TssSession object created by New-TssSession for authentication [Parameter(Mandatory, ValueFromPipeline, Position = 0)] [Thycotic.PowerShell.Authentication.Session] $TssSession, # Password Type ID [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [Alias('PasswordTypeId')] [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 ($passwordType in $Id) { $restResponse = $null $uri = $TssSession.ApiUrl, 'remote-password-changing', 'password-types', $passwordType -join '/' $invokeParams.Uri = $uri $invokeParams.Method = 'GET' Write-Verbose "Performing the operation $($invokeParams.Method) $($invokeParams.Uri)" try { $apiResponse = Invoke-TssApi @invokeParams $restResponse = . $ProcessResponse $apiResponse } catch { Write-Warning "Issue getting Password Type [$passwordType]" $err = $_ . $ErrorHandling $err } if ($restResponse) { # Pre-coerce each element of the nested Fields array so SS 12.0's wider PasswordTypeField # shape doesn't break the outer [PasswordType] cast. FilterTssResponse only filters the # outer object's properties; nested array element coercion needs to happen explicitly. if ($restResponse.fields) { $restResponse.fields = @( $restResponse.fields | ForEach-Object { [Thycotic.PowerShell.Rpc.PasswordTypeField](. $FilterTssResponse $_ ([Thycotic.PowerShell.Rpc.PasswordTypeField])) } ) } [Thycotic.PowerShell.Rpc.PasswordType](. $FilterTssResponse $restResponse ([Thycotic.PowerShell.Rpc.PasswordType])) } } } else { Write-Warning 'No valid session found' } } } |