rubrikinc / rubrik-powershell-sdk

The Rubrik Security Cloud SDK
https://www.powershellgallery.com/packages/RubrikSecurityCloud
MIT License
7 stars 9 forks source link

Get-RSCMSsqlDatabase cmdlet is not functional in 1.2 or 1.3 #96

Open McDBAOptPHC opened 2 months ago

McDBAOptPHC commented 2 months ago

Any attempt to run the cmdlet is returning this error.

InvalidOperation: C:\Program Files\PowerShell\Modules\RubrikSecurityCloud\1.3\Toolkit\Public\Get-RscMssqlDatabase.ps1:100:9
Line |
 100 |          $results = $query.Invoke()
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Method invocation failed because [System.String] does not contain a method named 'Invoke'.

I have verified that the problem happens with or without parameters:

PS D:\rubrik> Get-RscMssqlDatabase  -RscMssqlInstance $RscMssqlInstance -Debug
- Running Get-RscMssqlDatabase
InvalidOperation: C:\Program Files\PowerShell\Modules\RubrikSecurityCloud\1.3\Toolkit\Public\Get-RscMssqlDatabase.ps1:100:9
Line |
 100 |          $results = $query.Invoke()
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Method invocation failed because [System.String] does not contain a method named 'Invoke'.

PS D:\rubrik> Get-RSCMssqlDatabase  -Debug
- Running Get-RscMssqlDatabase
InvalidOperation: C:\Program Files\PowerShell\Modules\RubrikSecurityCloud\1.3\Toolkit\Public\Get-RscMssqlDatabase.ps1:100:9
Line |
 100 |          $results = $query.Invoke()
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Method invocation failed because [System.String] does not contain a method named 'Invoke'.

We are on 1.3 I updated just after seeing the issue.

PS D:\rubrik> Get-Module RubrikSecurityCloud -All

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     1.3                   RubrikSecurityCloud                 {Connect-Rsc, Disconnect-Rsc, Get-RscCmdlet, Get-RscFileset…}

Let me know if there are any other info that you need to dig in on this.

evcheng-rubrik commented 2 months ago

Hi @McDBAOptPHC ,

It seems like the default parameter value List is no longer working. While we fix this, please use Get-RSCMssqlDatabase -List and Get-RscMssqlInstance -List.

Thanks

McDBAOptPHC commented 2 months ago

That does work. However, we are also having issues passing instance values to the cmdlet. I confirmed that the instance cmdlet is returning a value.

 Get-RSCMssqlDatabase  -RscMssqlInstance $(Get-RSCMssqlInstance -HostName "MYHOST" -InstanceName "MYINSTANCE")[0]
InvalidOperation: C:\Program Files\PowerShell\Modules\RubrikSecurityCloud\1.3\Toolkit\Public\Get-RscMssqlDatabase.ps1:100:9
Line |
 100 |          $results = $query.Invoke()
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Method invocation failed because [System.String] does not contain a method named 'Invoke'.
clumnah commented 2 months ago

Fix in PR #97

evcheng-rubrik commented 2 months ago

@McDBAOptPHC We'll be releasing a fix shortly. In the meantime, you'll want to use the RscMssqlInstance parameter in combination with List to avoid the issue.

Something like Get-RSCMssqlDatabase -List -RscMssqlInstance

evcheng-rubrik commented 2 months ago

@McDBAOptPHC Apologies, I previously mispoke. Please use the following parameter set Get-RSCMssqlDatabase -Name $name -RscMssqlInstance $instance

McDBAOptPHC commented 2 months ago

I tried that I get the following error. (The passed variable is set using Get-RSCMSSQLInstance.

Get-RSCMSSQLDatabase -Name 'Master' -RscMssqlInstance $TestInstance
Get-RscMssqlDatabase: Cannot process argument transformation on parameter 'RscMssqlInstance'. Cannot convert the "System.Object[]" value of type "System.Object[]" to type "RubrikSecurityCloud.Types.MssqlInstance".

It looks like the return type from the Get-MSCSQlInstance may be an issue. I tried manually typing my variable for that cmdlet and ended up with the same error:

[RubrikSecurityCloud.Types.MssqlInstance]$TestInstance = Get-RSCMssqlInstance -HostName $TestHost.Name -InstanceName My_Instance
MetadataError: Cannot convert the "System.Object[]" value of type "System.Object[]" to type "RubrikSecurityCloud.Types.MssqlInstance".

Digging in a little bit it looks like it's returning two instances in the results but both objects in the array are identical both [0] and [1] have identical IDs. When I call either of those in the command it works as expected:

Get-RSCMSSQLDatabase -Name 'Master' -RscMssqlInstance $TestInstance[1]

However is there a way to get it to return all of the databases connected to an instance? Just for completeness, I wanted to update this with what I get when I try and just output an instance to the cmdlet

Get-RSCMSSQLDatabase -RscMssqlInstance $TestInstance[0]
InvalidOperation: C:\Program Files\PowerShell\Modules\RubrikSecurityCloud\1.3\Toolkit\Public\Get-RscMssqlDatabase.ps1:100:9
Line |
 100 |          $results = $query.Invoke()
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~
     | You cannot call a method on a null-valued expression.
PS D:\rubrik> Get-RSCMSSQLDatabase -RscMssqlInstance $TestInstance[1]
InvalidOperation: C:\Program Files\PowerShell\Modules\RubrikSecurityCloud\1.3\Toolkit\Public\Get-RscMssqlDatabase.ps1:100:9
Line |
 100 |          $results = $query.Invoke()
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~
     | You cannot call a method on a null-valued expression.