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

Most commands failing Compare-TSSVersion check #243

Closed GoldenGreek closed 3 years ago

GoldenGreek commented 3 years ago

Verified issue does not already exist?

Yes

What error did you receive

I'm able to connect to SecretServer with $tssession=New-TssSession -SecretServer https://FQDN/SecretServer -Credential (get-credential), but every command I try to issue thereafter returns with the following error (or similar, depending on which ps1 file the cmdlet is in):

Compare-TssVersion : Version string portion was too short or too long.
At C:\Program Files\WindowsPowerShell\Modules\Thycotic.SecretServer\0.58.0\functions\users\Search-TssUser.ps1:67 char:13

Looking at the source code, I decided to try setting the variable $tss_ignoreversioncheck=$true then calling the cmdlet, but I received the same errors on the cmdlets. I'm running the 0.58.0 version of the Thycotic SecretServer cmdlets that were installed via the powershell gallery.

Please run the command using -Verbose

PS C:\users\XXXX\work folders\scripts> Search-TssUser -TssSession $tssession -SearchText "XXX" -verbose
VERBOSE: Command invocation: Search-TssUser -TssSession:TssSessionObject -SearchText:epk -Verbose:True
Compare-TssVersion : Version string portion was too short or too long.
At C:\Program Files\WindowsPowerShell\Modules\Thycotic.SecretServer\0.58.0\functions\users\Search-TssUser.ps1:67 char:13
+             Compare-TssVersion $TssSession '10.9.000000' $PSCmdlet.My ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Compare-TssVersion], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException,Thycotic.SecretServer.Cmdlets.CompareVersionCmdlet

VERBOSE: Filters: filter.searchText=XXX
VERBOSE: Performing the operation GET https://FQDN/SecretServer/api/v1/users?sortBy[0].direction=asc&sortBy[0].name=DisplayName&take=2147483647&filter.searchText=XXX with:
WARNING: No Users found

Provide a test case or steps to reproduce

$tssession=New-TssSession -SecretServer "https://fqdn/SecretServer" -Credential (get-credential) Search-TssUser -TssSession $tssession -SearchText "XXX"

Expected behavior

Return list of users that match the sub-string "XXX"

What Edition of Secret Server?

Platinum

What version of Secret Server

11.0

What PowerShell host was used when producing this error

Windows PowerShell (powershell)

PowerShell Host Version

Name                           Value
----                           -----
PSVersion                      5.1.18362.1801
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.18362.1801
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
wsmelton commented 3 years ago

Version string portion was too short or too long.

All I can find on that message is it is coming from .NET and/or PowerShell checking the .NET builds on a machine and getting back to many versions.

The message commonly occurs on machines that have a high number of .NET versions installed. from the library being loaded and PowerShell trying to check the versions of .NET on the machine. I only have one version on my dev machine and cannot reproduce the error. At most I can adjust it where the call to that command would hide this message, but that does not mean other calls to the binary commands in the module won't error as well.

Do you happen to have a high number of .NET versions installed on the machine?

GoldenGreek commented 3 years ago

Interesting. I do have 5 different versions of .NET framework on this PC. Which version would you recommend? This PC is a corporate managed asset, so I'd have to work with our desktop group to see if we can whittle it down to 1. I will get back to you ASAP on results.

Thanks, -Pete

wsmelton commented 3 years ago

I'd probably start by removing the unsupported versions unless the company has in-house apps (or OTS apps) that needed them.

Support dates are listed here: https://dotnet.microsoft.com/download/dotnet-framework

GoldenGreek commented 3 years ago

Same error with just .NET Client 4.8.04084 installed. I also installed .Net Devpack (full) 4.8.04084 and received same error with that version of .Net as well. I also tried it on a Windows 10 VM as well, to make sure it wasn't my installation.

wsmelton commented 3 years ago

I was able to finally replicate. In my case I caused this to show up by disabling viewing version number of Secret Server.

In New-TssSession I do a call to Get-TssVersion to populate the property on the TssSession object, that in turn is used for comparing versions in each function call via the Compare-TssVersion (internal cmdlet). I changed the call to Get-TssVersion to no longer throw any errors from New-TssSession and then also had to adjust the internal command how it was comparing.

Next release will include the fix.