Skip to content

Get-TssSecretTemplate fails on casting [System.Management.Automation.PSCustomObject] to type [Thycotic.PowerShell.SecretTemplates.Template] #410

@dirtdonthurt

Description

@dirtdonthurt

Verified issue does not already exist?

Yes

What error did you receive

PSMessageDetails :
Exception : System.Management.Automation.RuntimeException: Cannot convert value "@{id=6087; concurrencyId=f82d1ef4-9dbf-4c1d-8181-802398d62a65; name=_VTK Linux Account; fields=System.Object[];
passwordTypeId=1056}" to type "Thycotic.PowerShell.SecretTemplates.Template". Error: "Cannot convert the "@{id=6087; concurrencyId=f82d1ef4-9dbf-4c1d-8181-802398d62a65; name=_VTK Linux
Account; fields=System.Object[]; passwordTypeId=1056}" value of type "System.Management.Automation.PSCustomObject" to type "Thycotic.PowerShell.SecretTemplates.Template"."
---> System.Management.Automation.PSInvalidCastException: Cannot convert value "@{id=6087; concurrencyId=f82d1ef4-9dbf-4c1d-8181-802398d62a65; name=_VTK Linux Account;
fields=System.Object[]; passwordTypeId=1056}" to type "Thycotic.PowerShell.SecretTemplates.Template". Error: "Cannot convert the "@{id=6087;
concurrencyId=f82d1ef4-9dbf-4c1d-8181-802398d62a65; name=_VTK Linux Account; fields=System.Object[]; passwordTypeId=1056}" value of type "System.Management.Automation.PSCustomObject" to
type "Thycotic.PowerShell.SecretTemplates.Template"."
---> System.Management.Automation.PSInvalidCastException: Cannot convert the "@{id=6087; concurrencyId=f82d1ef4-9dbf-4c1d-8181-802398d62a65; name=_VTK Linux Account;
fields=System.Object[]; passwordTypeId=1056}" value of type "System.Management.Automation.PSCustomObject" to type "Thycotic.PowerShell.SecretTemplates.Template".
---> System.InvalidOperationException: The property 'concurrencyId' was not found for the 'Thycotic.PowerShell.SecretTemplates.Template' object. The settable properties are: [Id
<System.Int32>], [Name <System.String>], [PasswordTypeId <System.Int32>], [Fields <Thycotic.PowerShell.SecretTemplates.Field[]>].
at System.Management.Automation.LanguagePrimitives.CreateMemberNotFoundError(PSObject pso, DictionaryEntry property, Type resultType)
at System.Management.Automation.LanguagePrimitives.SetObjectProperties(Object o, IDictionary properties, Type resultType, MemberNotFoundError memberNotFoundErrorAction,
MemberSetValueError memberSetValueErrorAction, Boolean enableMethodCall, IFormatProvider formatProvider, Boolean recursion, Boolean ignoreUnknownMembers)
at System.Management.Automation.LanguagePrimitives.SetObjectProperties(Object o, PSObject psObject, Type resultType, MemberNotFoundError memberNotFoundErrorAction, MemberSetValueError
memberSetValueErrorAction, IFormatProvider formatProvider, Boolean recursion, Boolean ignoreUnknownMembers)
--- End of inner exception stack trace ---
at System.Management.Automation.LanguagePrimitives.SetObjectProperties(Object o, PSObject psObject, Type resultType, MemberNotFoundError memberNotFoundErrorAction, MemberSetValueError
memberSetValueErrorAction, IFormatProvider formatProvider, Boolean recursion, Boolean ignoreUnknownMembers)
at System.Management.Automation.LanguagePrimitives.ConvertViaNoArgumentConstructor.Convert(Object valueToConvert, Type resultType, Boolean recursion, PSObject originalValueToConvert,
IFormatProvider formatProvider, TypeTable backupTable, Boolean ignoreUnknownMembers)
--- End of inner exception stack trace ---
at System.Management.Automation.LanguagePrimitives.ConvertViaNoArgumentConstructor.Convert(Object valueToConvert, Type resultType, Boolean recursion, PSObject originalValueToConvert,
IFormatProvider formatProvider, TypeTable backupTable, Boolean ignoreUnknownMembers)
at System.Management.Automation.LanguagePrimitives.ConvertViaNoArgumentConstructor.Convert(Object valueToConvert, Type resultType, Boolean recursion, PSObject originalValueToConvert,
IFormatProvider formatProvider, TypeTable backupTable)
at CallSite.Target(Closure, CallSite, Object)
at System.Management.Automation.Interpreter.DynamicInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
--- End of inner exception stack trace ---
TargetObject :
CategoryInfo : InvalidArgument: (:) [], RuntimeException
FullyQualifiedErrorId : InvalidCastConstructorException
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at Get-TssSecretTemplate, C:\Users\d452254\Documents\PowerShell\Modules\Thycotic.SecretServer\0.61.5\functions\secret-templates\Get-TssSecretTemplate.ps1: line 64
at , : line 1
PipelineIterationInfo : {}

Please run the command using -Verbose

PS C:\Users\d452254> Get-TssSecretTemplate -TemplateId 6087 -tsssession $session
InvalidArgument: C:\Users\d452254\Documents\PowerShell\Modules\Thycotic.SecretServer\0.61.5\functions\secret-templates\Get-TssSecretTemplate.ps1:64
Line |
64 | … [Thycotic.PowerShell.SecretTemplates.Template]$restRespon …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot convert value "@{id=6087; concurrencyId=f82d1ef4-9dbf-4c1d-8181-802398d62a65; name=_VTK Linux Account; fields=System.Object[]; passwordTypeId=1056}" to type
| "Thycotic.PowerShell.SecretTemplates.Template". Error: "Cannot convert the "@{id=6087; concurrencyId=f82d1ef4-9dbf-4c1d-8181-802398d62a65; name=_VTK Linux Account; fields=System.Object[];
| passwordTypeId=1056}" value of type "System.Management.Automation.PSCustomObject" to type "Thycotic.PowerShell.SecretTemplates.Template"."

Provide a test case or steps to reproduce

Call Get-TssSecretTemplate and supply a valid template ID and Session

Get-TssSecretTemplate -TemplateId 6087 -tsssession $session

Expected behavior

A Template object is returned matching the ID that was provided when the Commandlet was called

What Edition of Secret Server?

Cloud Subscription

What version of Secret Server

Secret Server Cloud

What PowerShell host was used when producing this error

PowerShell Core (pwsh)

PowerShell Host Version

PS /opt/git/secretserver-integrations> Get-InstalledModule Thycotic.SecretServer

Version Name Repository Description


0.61.8 Thycotic.SecretServer PSGallery Interact with the Secret Server REST API

PS /opt/git/secretserver-integrations> $psversionTable

Name Value


PSVersion 7.4.5
PSEdition Core
GitCommitId 7.4.5
OS Darwin 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage needednew issues that are still in state of triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions