vmware-archive / powernsx

PowerShell module that abstracts the VMware NSX-v API to a set of easily used PowerShell functions
173 stars 89 forks source link

Bug in Get-NsxLicense -- invalid comparison operation #529

Closed mtboren-lilly closed 6 years ago

mtboren-lilly commented 6 years ago

For starters -- great module, thanks for making/maintaining it for the world!

Issue: error received when invoking Get-NsxLicense. This seems to be due to the attempted comparison of a string and an undefined item (the unquoted 6.2.3 value):

    ## ...\PowerNSX\3.0.1110\PowerNSX.psm1, line 9677
    if ( $Connection.Version -gt 6.2.3) {

I assume that the intention is to do a comparison of [System.Version] objects, like:

[System.Version]$Connection.Version -gt [System.Version]"6.2.3"

The invocation of Get-NsxLicense generates the error:

The property '3' cannot be found on this object. Verify that the property exists.
At <...snip...>\PowerNSX\3.0.1110\PowerNSX.psm1:9677 char:14
+         if ( $Connection.Version -gt 6.2.3) {
+              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], PropertyNotFoundException
    + FullyQualifiedErrorId : PropertyNotFoundStrict

This is with a valid NSX connection in place as established by Connect-NsxServer, of course.

dcoghlan commented 6 years ago

Hi Matt

Thanks for logging the issue. Can you please provide the version of NSX-v that you are testing the command against, and also the output of $psversiontable.

Regards Dale

alagoutte commented 6 years ago

Get the same issue with PowerShell 5.0 (on Windows) and PowerCore 6.0(-alpha) on Ubuntu/Linux Push a fix (and add test) and also fix example

mtboren-lilly commented 6 years ago

Hello, @dcoghlan

Sure thing, here is some info:

PS C:\> $DefaultNSXConnection

Version             : 6.3.5
BuildNumber         : 7119875
...

PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.14409.1012
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14409.1012
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

And, I see that @alagoutte has pushed a fix that will seemingly resolve the issue if/when merged -- hurray!

Thanks, all