thycotic-ps / thycotic.secretserver

PowerShell module for automating with Thycotic Secret Server REST API
https://thycotic-ps.github.io/thycotic.secretserver
MIT License
68 stars 22 forks source link

InvalidArgument:[Thycotic.PowerShell.SecretTemplates.Summary[]]$restResponse] ... Cannot convert value "@{...}" #319

Closed TryTryAgain closed 1 year ago

TryTryAgain commented 1 year ago

Verified issue does not already exist?

Yes

What error did you receive

Similar to https://github.com/thycotic-ps/thycotic.secretserver/issues/271

What was working Friday of last week stopped working on Monday. I did open case #01115829 ...

The response is not coming back correctly. Instead of working as expected, it's erroring because the secret is not coming back as a proper custom PowerShell object or hashtable but instead as a string and then getting the error Cannot convert value "@{...}".

Please run the command using -Verbose

A simple test using Show-TssCurrentUser -TssSession $session -Verbose but the same is happening for most, but not all, other commands (ie: not working for Search-TssSecretTemplate as well as others but Get-TssSecret is actually still functioning just fine).

Session's User Info: VERBOSE: Command invocation: Show-TssCurrentUser -TssSession:TssSessionObject -Verbose:True VERBOSE: Performing the operation GET https://ourinstancename.secretservercloud.eu/api/v1/users/current SecretServer SecretServerVersion TokenType StartTime TimeOfDeath


https://ourinstancename.secretservercloud.eu/ 11.4.000002 bearer 3/1/2023 1:16:59 PM 3/1/2023 2:17:00 PM InvalidArgument: /Users/michael.lawler/.local/share/powershell/Modules/Thycotic.SecretServer/functions/users/Show-TssCurrentUser.ps1:63:17 Line | 63 | [Thycotic.PowerShell.Users.CurrentUser]$restResponse | ~~~~~~~~~~~~ | Cannot convert value "@{id=732; userName=Michael.Lawler; displayName=Michael Lawler; emailAddress=michael.lawler@omnicomgroup.com; dateOptionId=-1; | timeOptionId=-1; userLcid=-1; permissions=System.Object[]; profileLinks=System.Object[]; adminLinks=System.Object[]; userTheme=Secret Server - SPA; | platformIntegrationType=None}" to type "Thycotic.PowerShell.Users.CurrentUser". Error: "Cannot convert the "@{id=732; userName=Michael.Lawler; | displayName=Michael Lawler; emailAddress=michael.lawler@omnicomgroup.com; dateOptionId=-1; timeOptionId=-1; userLcid=-1; permissions=System.Object[]; | profileLinks=System.Object[]; adminLinks=System.Object[]; userTheme=Secret Server - SPA; platformIntegrationType=None}" value of type | "System.Management.Automation.PSCustomObject" to type "Thycotic.PowerShell.Users.CurrentUser"."

Provide a test case or steps to reproduce

Show-TssCurrentUser -TssSession $session -Verbose

Search-TssSecretTemplate -TssSession $session -SearchText 'AWS'

Find-TssUser -TssSession $session -Field Email -FindText "my.email@domain.com"

All actually come back with the same error: "InvalidArgument: [... and ...] Cannot convert value" ... And it appears that's happening because the response is somehow not exactly as it should be. As seen in the error above it looks like all the data is there but it's not being seen as a proper custom ps object or hashtable but instead as a string.

Expected behavior

That it would work without errors as it did a week ago.

What Edition of Secret Server?

Cloud Subscription

What version of Secret Server

11.0

What PowerShell host was used when producing this error

PowerShell Core (pwsh)

PowerShell Host Version

tested with 7.3.2 on CentOS 7 and 7.3.3 on MacOS 13.2.1

TryTryAgain commented 1 year ago

FYI, I had also opened this discussion https://github.com/thycotic-ps/thycotic.secretserver/discussions/318 wondering about the state of this module (with the Delinea rebranding etc. I noticed most of "Thycotic" repos are now "public archive".

Also wanted to add that when we first noticed the issue outlined in the OP we then went ahead and rewrote some scripts using the Invoke-RestMethod process as outlined by https://protect-eu.mimecast.com/s/tmHTCpR0Yi9mvBLRUJRSYr?domain=docs.delinea.com ... and rewriting to "add secret" using that method worked but we are getting similar errors when trying to update/"edit" an existing secret....where again the response seemed a bit off and instead of subsequently being able to call $secret.Name or set $secret.Active failed because those properties don't exist because it's not a proper object (the data is in there but trapped in a hashtable string instead of an actual hashtable. Hope that additional info helps.

TryTryAgain commented 1 year ago

So I see https://github.com/thycotic-ps/thycotic.secretserver/issues/321 is definitely related. I will try the workaround proposed here https://github.com/thycotic-ps/thycotic.secretserver/issues/321#issuecomment-1478211656 but would love to know what happened that fateful weekend and if/when you would please fix it so we don't need to fumble around with workarounds...

TryTryAgain commented 1 year ago

Looks like it may be fixed via https://github.com/thycotic-ps/thycotic.secretserver/pull/320 ... wonder when we can expect the updated module to be pushed. I'll try manually ASAP too. Thanks!