diff --git a/CHANGELOG.md b/CHANGELOG.md index fc4aa701..bdb35bb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * `New-TssSession` - `OtpCode` parameter is now `[string]` instead of `[int]`. OTP codes with leading zeros (e.g. `012345`) were being truncated by the integer coercion before reaching the API. Existing scripts that pass a numeric literal continue to work via PowerShell's implicit conversion. Fixes #316. * `Get-TssConfiguration` - fix `Cannot convert value ... to type Thycotic.PowerShell.Configuration.General` cast failure on SS 12.0. The outer `[General]` cast was applied to a response whose nested sub-objects (e.g. `email`, `applicationSettings`) still contained SS 12.0 fields not modeled by the C# classes. The cmdlet now constructs the `General` result by drilling into each known sub-object and running `FilterTssResponse` against it before assignment, so unknown nested fields are stripped instead of breaking the cast. Also handles the SS 12.0 rename of the `emailSettings` response property to `email`. Fixes #432. * `New-TssSession` - authentication failures that return no error detail (e.g. TLS certificate rejection) now surface a descriptive message. When the certificate is likely the cause, the error text explicitly suggests adding `-SkipCertificateCheck`. Fixes #442. +* `Get-TssRpcPasswordType` - fix `Cannot convert value ... to type Thycotic.PowerShell.Rpc.PasswordTypeField` cast failure on SS 12.0. The outer `[PasswordType]` cast left the nested `fields` array as untyped `PSCustomObject` elements, which PowerShell could not coerce. The cmdlet now pre-coerces each `fields` element through `FilterTssResponse` before the outer cast. Fixes #440. ### New Stuff diff --git a/src/functions/remote-password-changing/Get-TssRpcPasswordType.ps1 b/src/functions/remote-password-changing/Get-TssRpcPasswordType.ps1 index e233e00e..94730da7 100644 --- a/src/functions/remote-password-changing/Get-TssRpcPasswordType.ps1 +++ b/src/functions/remote-password-changing/Get-TssRpcPasswordType.ps1 @@ -60,6 +60,16 @@ function Get-TssRpcPasswordType { } 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])) } }