Skip to content

Commit

Permalink
Added DetailedObject parameter to Get User #651 🔬
Browse files Browse the repository at this point in the history
  • Loading branch information
jaapbrasser committed Sep 7, 2020
1 parent ef257eb commit 550fb06
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions Rubrik/Public/Get-RubrikUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,32 @@ function Get-RubrikUser
.EXAMPLE
Get-RubrikUser
This will return settings of all of the user accounts (local and LDAP) configured within the Rubrik cluster.
.EXAMPLE
Get-RubrikUser -authDomainId 'local'
This will return settings of all of the user accounts belonging to the local authoriation domain.
.EXAMPLE
Get-RubrikUser -username 'john.doe'
This will return settings for the user account with the username of john.doe configured within the Rubrik cluster.
.EXAMPLE
Get-RubrikUser -username 'john.doe' -DetailedObject
This will return full details of the settings for the user account with the username of john.doe configured within the Rubrik cluster.
.EXAMPLE
Get-RubrikUser -authDomainId '1111-222-333'
This will return settings of all of the user accounts belonging to the specified authoriation domain.
.EXAMPLE
Get-RubrikUser -id '1111-22222-33333-4444-5555'
This will return detailed information about the user with the specified ID.
#>

Expand All @@ -55,6 +65,8 @@ function Get-RubrikUser
Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
[String]$Id,
# DetailedObject will retrieved the detailed User object, the default behavior of the API is to only retrieve a subset of the full User 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 @@ -97,9 +109,18 @@ function Get-RubrikUser
$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-RubrikUser -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 550fb06

Please sign in to comment.