Skip to content
Merged
Show file tree
Hide file tree
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
20 changes: 17 additions & 3 deletions psPAS/Functions/Accounts/Get-PASAccount.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,15 @@ function Get-PASAccount {
Mandatory = $false,
ValueFromPipelineByPropertyName = $false
)]
[int]$TimeoutSec
[int]$TimeoutSec,

[parameter(
Mandatory = $false,
ValueFromPipelineByPropertyName = $false,
ParameterSetName = 'Gen2Query'
)]
[ValidateSet('AND', 'OR')]
[string]$LogicalOperator = 'AND'

)

Expand All @@ -101,7 +109,7 @@ function Get-PASAccount {
$paramDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary

# List of existing static parameters to avoid duplicates
$existingParams = @('id', 'search', 'searchType', 'safeName', 'savedFilter', 'modificationTime', 'sort', 'limit', 'Keywords', 'Safe', 'TimeoutSec')
$existingParams = @('id', 'search', 'searchType', 'safeName', 'savedFilter', 'modificationTime', 'sort', 'limit', 'Keywords', 'Safe', 'TimeoutSec', 'LogicalOperator')

# Create dynamic parameter for each search property not already defined
foreach ($property in $SearchProperties) {
Expand Down Expand Up @@ -150,7 +158,13 @@ function Get-PASAccount {
#Get Parameters to include in request
$boundParameters = $PSBoundParameters | Get-PASParameter -ParametersToRemove $Parameters
$filterParameters = $PSBoundParameters | Get-PASParameter -ParametersToKeep $Parameters
$FilterString = $filterParameters | ConvertTo-FilterString

# Only use LogicalOperator for API 14.6+
if ($PSCmdlet.ParameterSetName -eq 'Gen2Query' -and $psPASSession.ExternalVersion -ge [version]'14.6') {
$FilterString = $filterParameters | ConvertTo-FilterString -LogicalOperator $LogicalOperator
} else {
$FilterString = $filterParameters | ConvertTo-FilterString
}

switch ($PSCmdlet.ParameterSetName) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# .ExternalHelp psPAS-help.xml
Function Get-PASPTASecurityConfigurationCategory {
[CmdletBinding(SupportsShouldProcess = $false, DefaultParameterSetName = 'ListAllCategories')]
param(
[parameter(
Mandatory = $false,
ValueFromPipelinebyPropertyName = $false,
ParameterSetName = 'ListAllCategories'
)]
[switch]$ListAllCategories,
[parameter(
Mandatory = $false,
ValueFromPipelinebyPropertyName = $false,
ParameterSetName = 'categoryKey'
)]
[ValidateSet('ActiveDormantUser', 'PrivilegedUsersAndGroups', 'IrregularIpUser', 'SuspectedCredentialsTheft', 'InteractiveLogonWithServiceAccount',
'IrregularHoursUser', 'UnmanagedPrivilegedAccess', 'SuspiciousActivityInPSMSession', 'IrregularDaysUser', 'FailedVaultLogonAttempts',
'ExcessiveAccessUser', 'SuspiciousPasswordChange')]
[Alias('Category')]
[string]$categoryKey
)

BEGIN {
Assert-VersionRequirement -SelfHosted
Expand All @@ -8,23 +27,48 @@ Function Get-PASPTASecurityConfigurationCategory {

PROCESS {

#Create request URL
$URI = "$($psPASSession.BaseURI)/API/pta/API/configuration/categories"
switch ($PSCmdlet.ParameterSetName) {

#send request to web service
$result = Invoke-PASRestMethod -Uri $URI -Method GET
'ListAllCategories' {

If ($null -ne $result) {
#Create request URL
$URI = "$($psPASSession.BaseURI)/API/pta/API/configuration/categories"

#send request to web service
$result = Invoke-PASRestMethod -Uri $URI -Method GET

If ($null -ne $result) {

#Return Results as objects
$result | ForEach-Object {
[PSCustomObject]@{
Category = $_
}
}

}

}

'categoryKey' {

#Create URL for Request
$URI = "$($psPASSession.BaseURI)/API/pta/API/configuration/categories/$categoryKey"

#send request to web service
$result = Invoke-PASRestMethod -Uri $URI -Method GET

If ($null -ne $result) {

$result

#Return Results as objects
$result | ForEach-Object {
[PSCustomObject]@{
Category = $_
}

}

}


}#process

END { }#end
Expand Down
15 changes: 13 additions & 2 deletions psPAS/Private/ConvertTo-FilterString.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ Encloses value of the key/value pair in quotes.
Mandatory = $false,
ValueFromPipeline = $false
)]
[switch]$QuoteValue
[switch]$QuoteValue,

[parameter(
Mandatory = $false,
ValueFromPipeline = $false
)]
[string]$LogicalOperator
)

Begin {
Expand Down Expand Up @@ -113,7 +119,12 @@ Encloses value of the key/value pair in quotes.

If ($FilterList.count -gt 0) {

@{'filter' = $FilterList -join ' AND ' }
# Only use LogicalOperator for API 14.6+, default to AND for older versions
if ($ExternalVersion -and $ExternalVersion -ge [version]'14.6') {
@{'filter' = $FilterList -join " $LogicalOperator " }
} else {
@{'filter' = $FilterList -join ' AND ' }
}

}
}
Expand Down