-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
242 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
category: groups | ||
title: "TssGroupLookup" | ||
last_modified_at: 2021-05-26T00:00:00-00:00 | ||
--- | ||
|
||
# TOPIC | ||
This help topic describes the TssGroupLookup class in the Thycotic.SecretServer module | ||
|
||
# CLASS | ||
TssGroupLookup | ||
|
||
# INHERITANCE | ||
None | ||
|
||
# DESCRIPTION | ||
The TssGroupLookup class represents the GroupLookup object returned by Secret Server endpoint GET /groups/lookup | ||
|
||
# CONSTRUCTORS | ||
new() | ||
|
||
# PROPERTIES | ||
Documented in the REST API doc for Secret Server, see GroupLookup definition | ||
|
||
# METHODS | ||
|
||
# RELATED LINKS: | ||
Find-TssGroup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class TssGroupLookup { | ||
[int] | ||
$Id | ||
|
||
[string] | ||
$Value | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
TOPIC | ||
This help topic describes the TssGroupLookup class in the Thycotic.SecretServer module | ||
|
||
CLASS | ||
TssGroupLookup | ||
|
||
INHERITANCE | ||
None | ||
|
||
DESCRIPTION | ||
The TssGroupLookup class represents the GroupLookup object returned by Secret Server endpoint GET /groups/lookup | ||
|
||
CONSTRUCTORS | ||
new() | ||
|
||
PROPERTIES | ||
Documented in the REST API doc for Secret Server, see GroupLookup definition | ||
|
||
METHODS | ||
|
||
RELATED LINKS: | ||
Find-TssGroup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
function Find-Group { | ||
<# | ||
.SYNOPSIS | ||
Find for a Secret Server Group | ||
.DESCRIPTION | ||
Find for a Secret Server Group (domain or local) | ||
.LINK | ||
https://thycotic-ps.github.io/thycotic.secretserver/commands/Find-TssGroup | ||
.LINK | ||
https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/groups/Find-Group.ps1 | ||
.EXAMPLE | ||
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred | ||
Find-TssGroup -TssSession $session -DomainId 1 | ||
Return list of Groups found in Secret Server for Domain Directory 1 | ||
.EXAMPLE | ||
$session = New-TssSession -SecretServer https://alpha/SecretServer -Credential $ssCred | ||
Find-TssGroup -TssSession $session -SearchText 'IT' | ||
Return list of Groups found in Secret Server matching the characters IT | ||
.NOTES | ||
Requires TssSession object returned by New-TssSession | ||
#> | ||
[CmdletBinding()] | ||
[OutputType('TssGroupLookup')] | ||
param ( | ||
# TssSession object created by New-TssSession for auth | ||
[Parameter(Mandatory, ValueFromPipeline, Position = 0)] | ||
[TssSession] | ||
$TssSession, | ||
|
||
# Director Services Domain Id | ||
[int] | ||
$DomainId, | ||
|
||
# Limit to groups the current user can view details | ||
[switch] | ||
$ViewableGroups, | ||
|
||
# Search text | ||
[string] | ||
$SearchText, | ||
|
||
# Include inactive Groups | ||
[switch] | ||
$IncludeInactive, | ||
|
||
# Sort by specific property, default Name | ||
[string] | ||
$SortBy = 'Name' | ||
) | ||
begin { | ||
$tssParams = $PSBoundParameters | ||
$invokeParams = . $GetInvokeTssParams $TssSession | ||
} | ||
process { | ||
Write-Verbose "Provided command parameters: $(. $GetInvocation $PSCmdlet.MyInvocation)" | ||
if ($tssParams.ContainsKey('TssSession') -and $TssSession.IsValidSession()) { | ||
. $CheckVersion $TssSession '10.9.000000' $PSCmdlet.MyInvocation | ||
$restResponse = $null | ||
$uri = $TssSession.ApiUrl, 'groups', 'lookup' -join '/' | ||
$uri = $uri, "sortBy[0].direction=asc&sortBy[0].name=$SortBy&take=$($TssSession.Take)" -join '?' | ||
$invokeParams.Method = 'GET' | ||
|
||
$filters = @() | ||
switch ($tssParams.Keys) { | ||
'DomainId' { $filters += "filter.domainId=$DomainId" } | ||
'IncludeInactive' { $filters += "filter.includeInactive=$([boolean]$IncludeInactive)" } | ||
'ViewableGroups' { $filters += "filter.limitToViewableGroups=$([boolean]$ViewableGroups)" } | ||
'SearchText' { $filters += "filter.searchText=$SearchText" } | ||
} | ||
if ($filters) { | ||
$uriFilter = $filters -join '&' | ||
Write-Verbose "Filters: $uriFilter" | ||
$uri = $uri, $uriFilter -join '&' | ||
} | ||
$invokeParams.Uri = $uri | ||
|
||
Write-Verbose "Performing the operation $($invokeParams.Method) $uri" | ||
try { | ||
$restResponse = . $InvokeApi @invokeParams | ||
} catch { | ||
Write-Warning "Issue on find request" | ||
$err = $_ | ||
. $ErrorHandling $err | ||
} | ||
|
||
if ($restResponse.records.Count -le 0 -and $restResponse.records.Length -eq 0) { | ||
Write-Warning "No Group found" | ||
} | ||
if ($restResponse.records) { | ||
[TssGroupLookup[]]$restResponse.records | ||
} | ||
} else { | ||
Write-Warning "No valid session found" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
BeforeDiscovery { | ||
$commandName = Split-Path ($PSCommandPath.Replace('.Tests.ps1','')) -Leaf | ||
. ([IO.Path]::Combine([string]$PSScriptRoot, '..', 'constants.ps1')) | ||
} | ||
Describe "$commandName verify parameters" { | ||
BeforeDiscovery { | ||
[object[]]$knownParameters = 'TssSession', 'DomainId', 'IncludeInactive', 'SearchText', 'ViewableGroups' | ||
[object[]]$currentParams = ([Management.Automation.CommandMetaData]$ExecutionContext.SessionState.InvokeCommand.GetCommand($commandName,'Function')).Parameters.Keys | ||
[object[]]$commandDetails = [System.Management.Automation.CommandInfo]$ExecutionContext.SessionState.InvokeCommand.GetCommand($commandName,'Function') | ||
$unknownParameters = Compare-Object -ReferenceObject $knownParameters -DifferenceObject $currentParams -PassThru | ||
} | ||
Context "Verify parameters" -Foreach @{currentParams = $currentParams } { | ||
It "$commandName should contain <_> parameter" -TestCases $knownParameters { | ||
$_ -in $currentParams | Should -Be $true | ||
} | ||
It "$commandName should not contain parameter: <_>" -TestCases $unknownParameters { | ||
$_ | Should -BeNullOrEmpty | ||
} | ||
} | ||
Context "Command specific details" { | ||
It "$commandName should set OutputType to TssGroupLookup" -TestCases $commandDetails { | ||
$_.OutputType.Name | Should -Be 'TssGroupLookup' | ||
} | ||
} | ||
} |