Skip to content

Commit

Permalink
Added DetailedObject to Get vCenter #651 🔬
Browse files Browse the repository at this point in the history
  • Loading branch information
jaapbrasser committed Sep 7, 2020
1 parent 550fb06 commit d580b65
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions Rubrik/Public/Get-RubrikVCenter.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ function Get-RubrikVCenter
.EXAMPLE
Get-RubrikVCenter
This will return the vCenter settings on the currently connected Rubrik cluster
.EXAMPLE
Get-RubrikVCenter -DetailedObject
This will return the detailed vCenter settings from currently connected Rubrik cluster
#>

[CmdletBinding()]
Expand All @@ -25,9 +31,17 @@ function Get-RubrikVCenter
[String]$Name,
# Rubrik server IP or FQDN
[String]$Server = $global:RubrikConnection.server,
# vCenter id
[Parameter(
ValueFromPipelineByPropertyName = $true
)]
[ValidateNotNullOrEmpty()]
[String]$id,
# Filter the summary information based on the primarycluster_id of the primary Rubrik cluster. Use 'local' as the primary_cluster_id of the Rubrik cluster that is hosting the current REST API session.
[Alias('primary_cluster_id')]
[String]$PrimaryClusterID,
[String]$PrimaryClusterID,
# DetailedObject will retrieved the detailed Nutanix VM object, the default behavior of the API is to only retrieve a subset of the full Nutanix VM object unless we query directly by ID. Using this parameter does affect performance as more data will be retrieved and more API-queries will be performed.
[Switch]$DetailedObject,
# API version
[ValidateNotNullorEmpty()]
[String]$api = $global:RubrikConnection.api
Expand Down Expand Up @@ -61,9 +75,18 @@ function Get-RubrikVCenter
$result = Submit-Request -uri $uri -header $Header -method $($resources.Method) -body $body
$result = Test-ReturnFormat -api $api -result $result -location $resources.Result
$result = Test-FilterObject -filter ($resources.Filter) -result $result
$result = Set-ObjectTypeName -TypeName $resources.ObjectTName -result $result

return $result

if (($DetailedObject) -and (-not $PSBoundParameters.containskey('id'))) {
for ($i = 0; $i -lt @($result).Count; $i++) {
$Percentage = [int]($i/@($result).count*100)
Write-Progress -Activity "DetailedObject queries in Progress, $($i+1) out of $(@($result).count)" -Status "$Percentage% Complete:" -PercentComplete $Percentage
if ($result) {
Get-RubrikVCenter -id $result[$i].id
}
}
} else {
$result = Set-ObjectTypeName -TypeName $resources.ObjectTName -result $result
return $result
}
} # End of process
} # End of function

0 comments on commit d580b65

Please sign in to comment.