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

Converting $restReponse to [Thycotic.PowerShell.Users.User] gives error #398

Open deickhoff opened 6 months ago

deickhoff commented 6 months ago

Verified issue does not already exist?

Yes

What error did you receive

InvalidArgument: C:\Program Files\PowerShell\7\Modules\Thycotic.SecretServer\functions\users\Get-TssUser.ps1:67 Line | 67 | [Thycotic.PowerShell.Users.User]$restResponse | ~~~~~~~~~ | Cannot convert value "@{DATA}" value of type | "System.Management.Automation.PSCustomObject" to type "Thycotic.PowerShell.Users.User"."

Please run the command using -Verbose

VERBOSE: Command invocation: get-tssuser -TssSession:TssSessionObject -Id:System.Int32[] -Verbose:True VERBOSE: Performing the operation GET https://ridutrecht.secretservercloud.eu/api/v1/users/2 InvalidArgument: C:\Program Files\PowerShell\7\Modules\Thycotic.SecretServer\functions\users\Get-TssUser.ps1:67 Line | 67 | [Thycotic.PowerShell.Users.User]$restResponse | ~~~~~~~~~ | Cannot convert value "@{DATA}" value of type | "System.Management.Automation.PSCustomObject" to type "Thycotic.PowerShell.Users.User"."

Provide a test case or steps to reproduce

For example Get-TssUser -TssSession $Session -Id 7 gives the error. But also the Update-TssUser gives the error, maybe for other commands too, but I haven't tried that.

Expected behavior

I expect the output to be usable. I still can read the output, like the properties of the given user, but it's not usable because I can't store it in a variable for example.

Possible solution: I removed [Thycotic.PowerShell.Users.User] from the Get-TssUser module (see here) and then it works fine.

I'm not sure if this is a bug or not or that something is wrong with my Powershell instance, but either way there should be a fix.

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

7

jagger commented 6 months ago

@deickhoff please provide output examples for get-tssuser and update-tssuser with -verbose enabled per question 3

deickhoff commented 6 months ago

@jagger I updated the ticket. I didn't include the verbose because I had the idea that it was not useful. I also updated the error message so its complete!

jagger commented 5 months ago

User class missing platformServiceUser