Skip to content

Commit

Permalink
Added -DetailedObject switch #651
Browse files Browse the repository at this point in the history
  • Loading branch information
jaapbrasser committed Sep 7, 2020
1 parent d859b31 commit 7653e69
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions Rubrik/Public/Get-RubrikHyperVVM.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,22 @@ function Get-RubrikHyperVVM
.EXAMPLE
Get-RubrikHyperVVM -Name 'Server1'
This will return details on all Hyper-V virtual machines named "Server1".
.EXAMPLE
Get-RubrikHyperVVM -Name 'Server1' -SLA Gold
This will return details on all Hyper-V virtual machines named "Server1" that are protected by the Gold SLA Domain.
.EXAMPLE
Get-RubrikHyperVVM -Name 'Server1' -DetailedObject
This will return all Hyper-V virtual machines named "Server1" and returns the Detailed Objects of these VMs
.EXAMPLE
Get-RubrikHyperVVM -Relic
This will return all removed Hyper-V virtual machines that were formerly protected by Rubrik.
#>

Expand Down Expand Up @@ -65,6 +73,8 @@ function Get-RubrikHyperVVM
[Parameter(ParameterSetName='Query')]
[Alias('effective_sla_domain_id')]
[String]$SLAID,
# DetailedObject will retrieved the detailed Hyper-V VM object, the default behavior of the API is to only retrieve a subset of the full Hyper-V 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,
# Rubrik server IP or FQDN
[Parameter(ParameterSetName='Query')]
[Parameter(ParameterSetName='ID')]
Expand Down Expand Up @@ -112,8 +122,17 @@ function Get-RubrikHyperVVM
$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-RubrikHyperVVM -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 7653e69

Please sign in to comment.