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

Find-TppObject can use -recursive twice #154

Merged
merged 1 commit into from
Oct 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions VenafiPS/Public/Find-TppObject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ function Find-TppObject {
Method = 'Post'
Body = @{
'ObjectDN' = $Path | ConvertTo-TppFullPath

}
}

Expand All @@ -152,13 +151,13 @@ function Find-TppObject {
$params.UriLeaf = 'config/find'
# this is the only api for this function which doesn't accept a path, let's remove it
$params.Body.Remove('ObjectDN')
$params.Body['AttributeNames'] = $Attribute
$params.Body.AttributeNames = $Attribute
}

{ $_ -in 'FindByPath', 'FindByPattern', 'FindByClass' } {
# if a path wasn't provided, default to recursive enumeration of \ved\policy
if ( -not $PSBoundParameters.ContainsKey('Path') ) {
$params.Body['Recursive'] = 'true'
$params.Body.Recursive = 'true'
}
}

Expand All @@ -174,17 +173,17 @@ function Find-TppObject {

# add filters
if ( $PSBoundParameters.ContainsKey('Pattern') ) {
$params.Body.Add( 'Pattern', $Pattern )
$params.Body.Pattern = $Pattern
}

if ( $PSBoundParameters.ContainsKey('Recursive') ) {
$params.Body.Add( 'Recursive', 'true' )
$params.Body.Recursive = 'true'
}

if ( $PSBoundParameters.ContainsKey('Class') ) {
# the rest api doesn't have the ability to search for multiple classes and path at the same time
# loop through classes to get around this
$params.Body['Class'] = ''
$params.Body.Class = ''
$objects = $Class.ForEach{
$thisClass = $_
$params.Body.Class = $thisClass
Expand Down