Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dirtdonthurt opened this issue Oct 17, 2024 · 1 comment
Labels
bug Something isn't working triage needed new issues that are still in state of triage

Comments

@dirtdonthurt
Copy link

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

@dirtdonthurt dirtdonthurt added bug Something isn't working triage needed new issues that are still in state of triage labels Oct 17, 2024
gaurava-delinea added a commit to gaurava-delinea/thycotic.secretserver that referenced this issue Nov 29, 2024
tylerezimmerman pushed a commit that referenced this issue Dec 2, 2024
@helarnl
Copy link

helarnl commented Dec 6, 2024

Hi, thanks for the fix. Will the PowerShell Gallery version updated or how can I utilize this fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage needed new issues that are still in state of triage
Projects
None yet
Development

No branches or pull requests

2 participants