Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
McDBAOptPHC opened this issue May 9, 2024 · 6 comments
Open

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

McDBAOptPHC opened this issue May 9, 2024 · 6 comments
Assignees

Comments

@McDBAOptPHC
Copy link

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
Copy link
Contributor

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
Copy link
Author

McDBAOptPHC commented May 9, 2024

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 clumnah self-assigned this May 9, 2024
clumnah added a commit to clumnah/rubrik-powershell-sdk that referenced this issue May 10, 2024
@clumnah
Copy link
Collaborator

clumnah commented May 10, 2024

Fix in PR #97

@evcheng-rubrik
Copy link
Contributor

@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
Copy link
Contributor

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

@McDBAOptPHC
Copy link
Author

McDBAOptPHC commented May 20, 2024

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.

evcheng-rubrik pushed a commit to evcheng-rubrik/rubrik-powershell-sdk that referenced this issue Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants