rubrik-sdk-for-powershell
rubrik-sdk-for-powershell copied to clipboard
Get-RubrikDatabase and "-ServerInstance" not working correctly for failover clusters in Rubrik CDM 5.3.
Current Behavior:
In Rubrik 5.2 (not PowerShell module 5.2), it worked to use Get-RubrikDatabase with -ServerInstance and specify it using "<server>\<instance>"
. It doesn't work after upgrading the Rubrik cluster to 5.3.1 - in that case, it is necessary to use "-InstanceId"
.
PS C:\Users\Jan> Get-RubrikDatabase -ServerInstance "JANSQLVIP\MYMSSQL" -verbose
VERBOSE: Validate the Rubrik token exists
VERBOSE: Found a Rubrik token for authentication
VERBOSE: Gather API Data for Get-RubrikDatabase
VERBOSE: Selected 1.0 API Data for Get-RubrikDatabase
VERBOSE: Load API data for Get-RubrikDatabase
VERBOSE: Description: Returns a list of summary information for Microsoft SQL databases.
VERBOSE: Validate the Rubrik token exists
VERBOSE: Found a Rubrik token for authentication
VERBOSE: Gather API Data for Get-RubrikSQLInstance
VERBOSE: Selected 1.0 API Data for Get-RubrikSQLInstance
VERBOSE: Load API data for Get-RubrikSQLInstance
VERBOSE: Description: Returns a list of summary information for Microsoft SQL instances.
VERBOSE: Build the URI
VERBOSE: URI = https://192.168.75.193/api/v1/mssql/instance
VERBOSE: Build the query parameters for instance_id,primary_cluster_id
VERBOSE: URI = https://192.168.75.193/api/v1/mssql/instance
VERBOSE: Submitting the request
VERBOSE: Invoking request with a custom timeout of 180 seconds
VERBOSE: GET https://192.168.75.193/api/v1/mssql/instance with 0-byte payload
VERBOSE: received 49021-byte response of content type application/json
VERBOSE: Received HTTP Status 200
VERBOSE: Formatting return value
VERBOSE: Filter the results
VERBOSE: Filter match = Name
VERBOSE: Filter match = Hostname
VERBOSE: Filter match = SLA
VERBOSE: Applying Rubrik.MSSQLInstance TypeName to results
VERBOSE: Build the URI
VERBOSE: URI = https://192.168.75.193/api/v1/mssql/db
VERBOSE: Build the query parameters for availability_group_id,instance_id,primary_cluster_id,effective_sla_domain_id
VERBOSE: URI = https://192.168.75.193/api/v1/mssql/db?instance_id=MssqlInstance:::391a24d2-42e2-4a34-ba13-10eaa1a14cee
VERBOSE: Submitting the request
VERBOSE: Invoking request with a custom timeout of 180 seconds
VERBOSE: GET https://192.168.75.193/api/v1/mssql/db?instance_id=MssqlInstance:::391a24d2-42e2-4a34-ba13-10eaa1a14cee with 0-byte payload
VERBOSE: received 36143-byte response of content type application/json
VERBOSE: Received HTTP Status 200
VERBOSE: Formatting return value
VERBOSE: Filter the results
VERBOSE: Filter match = AvailabilityGroupID
VERBOSE: Filter match = Instance
VERBOSE: Filter match = Name
VERBOSE: Filter match = Hostname
VERBOSE: Filter match = SLA
PS C:\Users\Jan>
PS C:\Users\Jan\> Get-RubrikDatabase -InstanceID $(Get-RubrikSQLInstance -Name MYMSSQL).ID -verbose
VERBOSE: Validate the Rubrik token exists
VERBOSE: Found a Rubrik token for authentication
VERBOSE: Gather API Data for Get-RubrikDatabase
VERBOSE: Selected 1.0 API Data for Get-RubrikDatabase
VERBOSE: Load API data for Get-RubrikDatabase
VERBOSE: Description: Returns a list of summary information for Microsoft SQL databases.
VERBOSE: Build the URI
VERBOSE: URI = https://192.168.75.193/api/v1/mssql/db
VERBOSE: Build the query parameters for availability_group_id,instance_id,primary_cluster_id,effective_sla_domain_id
VERBOSE: URI = https://192.168.75.193/api/v1/mssql/db?instance_id=MssqlInstance:::391a24d2-42e2-4a34-ba13-10eaa1a14cee
VERBOSE: Submitting the request
VERBOSE: Invoking request with a custom timeout of 180 seconds
VERBOSE: GET https://192.168.75.193/api/v1/mssql/db?instance_id=MssqlInstance:::391a24d2-42e2-4a34-ba13-10eaa1a14cee with 0-byte payload
VERBOSE: received 19986-byte response of content type application/json
VERBOSE: Received HTTP Status 200
VERBOSE: Formatting return value
VERBOSE: Filter the results
VERBOSE: Filter match = AvailabilityGroupID
VERBOSE: Filter match = Instance
VERBOSE: Filter match = Name
VERBOSE: Filter match = Hostname
VERBOSE: Filter match = SLA
VERBOSE: Applying Rubrik.MSSQLDatabase TypeName to results
Name Instance Name Recovery Model SLA Domain ID
---- ------------- -------------- ---------- --
Cats JANSQLVIP\MYMSSQL SIMPLE Gold DBs MssqlDatabase:::ba6979b8-575c-c60a-a9ce-bdca08aca55b
Dogs JANSQLVIP\MYMSSQL BULK_LOGGED Gold DBs MssqlDatabase:::b9cd2bb6-ccac-cabb-8558-a6b8c9c9e7bb
Cars JANSQLVIP\MYMSSQL BULK_LOGGED Gold DBs MssqlDatabase:::bacccab6-bcbb-ca88-90b6-0bd6cb9cb7b9
msdb JANSQLVIP\MYMSSQL SIMPLE Gold DBs MssqlDatabase:::c5aabb6b-cd5e-cb6d-aaca-d8cebcada7aa
model JANSQLVIP\MYMSSQL FULL Gold DBs MssqlDatabase:::89ab7c05-ec08-c75a-985b-9870a9a8c0ca
master JANSQLVIP\MYMSSQL SIMPLE Gold DBs MssqlDatabase:::aba5a797-6adb-c5c6-8ba2-ecd55eb55a7b
Expected Behavior:
When using Get-RubrikDatabase with -ServerInstance, it should be sufficient to use a single backslash and return output (JANSQLVIP\MYMSSQL).
Steps to Reproduce:
- Setup a Windows Cluster with SQL.
- Add it to Rubrik and discover DBs.
- Run Get-RubrikDatabase -ServerInstance "
<instance>" .
Context:
- Rubrik PowerShell Module Version:
PS C:\Users\Jan> Get-Module -ListAvailable Rubrik
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 5.3.0 Rubrik {Connect-Rubrik, Disconnect-Rubrik, Export-RubrikDatabase,...
- PowerShell Version:
PS C:\Users\Jan> $PSVersiontable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 1 19041 1023
- Operating System:
PS C:\Users\Jan> (Get-WMIObject win32_operatingsystem).Name
Microsoft Windows 10 Pro|C:\Windows|\Device\Harddisk0\Partition3
Failure Logs
None
I think there is some confusion behind what ServerInstance is.
ServerInstance should never be used for the Host\MSSQLSERVER combination. When you have a default instance, a default instance is one where the name of the instance is MSSQLSERVER, then the value put into ServerInstance is just the host name. When you have a named instance, a named instance is any value other than MSSQLSERVER, then the value put into ServerInstance is HOST\InstanceName.
When you have a failover cluster, this changes slightly. You do not use a hostname. Host name will refer to a node of a cluster. SQL Server when installed in as an FCI will create a virtual name. It will either be a default instance or named instance. When connecting to SQL Server that is installed as an FCI, then you would connect as just the Virtual Name if a default instance, or Virtual Name\InstanceName if a named instance.
With Rubrik, Rubrik does not understand the concept of a Virtual Name (the virtual name is actually a resource under each cluster resource). All FCIs are registered under their Windows Cluster Name. To use a Rubrik cmdlet with an FCI in Rubrik, you would use Windows Cluster Name\Instance name in the ServerInstance parameter.
@clumnah I've edited the original description and findings. Also discussed with @jaapbrasser in private.