functions/discovery/Get-TssDiscoveryAccountRuleMatch.ps1
|
function Get-TssDiscoveryAccountRuleMatch { <# .SYNOPSIS Get computer accounts that match a Discovery account rule .DESCRIPTION Returns the discovered computer accounts that the Discovery account rule matches, with the computer, organizational unit and any secret already linked. .PARAMETER TssSession TssSession object created by New-TssSession for authentication .PARAMETER Id Discovery account rule id .EXAMPLE $session = New-TssSession -SecretServer https://alpha -Credential $ssCred Get-TssDiscoveryAccountRuleMatch -TssSession $session -Id 3 Get the computer accounts matched by Discovery account rule 3 .LINK https://thycotic-ps.github.io/thycotic.secretserver/commands/discovery/Get-TssDiscoveryAccountRuleMatch .LINK https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/discovery/Get-TssDiscoveryAccountRuleMatch.ps1 .NOTES Requires TssSession object returned by New-TssSession #> [CmdletBinding()] [OutputType('Thycotic.PowerShell.Discovery.AccountRuleMatch[]')] param ( [Parameter(Mandatory, ValueFromPipeline, Position = 0)] [Thycotic.PowerShell.Authentication.Session] $TssSession, [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [Alias('AccountRuleId', 'RuleId')] [int[]] $Id ) begin { $tssParams = $PSBoundParameters $invokeParams = . $GetInvokeApiParams $TssSession } process { Get-TssInvocation $PSCmdlet.MyInvocation if ($tssParams.ContainsKey('TssSession') -and $TssSession.IsValidSession()) { Compare-TssVersion $TssSession '10.9.000000' $PSCmdlet.MyInvocation foreach ($currentId in $Id) { $restResponse = $null $uri = $TssSession.ApiUrl, 'discovery', 'rules', 'accounts', $currentId, 'matches' -join '/' $queryParams = @() $queryParams += "take=$($TssSession.Take)" if ($queryParams) { $uri = $uri, ($queryParams -join '&') -join '?' } $invokeParams.Uri = $uri $invokeParams.Method = 'GET' Write-Verbose "Performing the operation $($invokeParams.Method) $uri" try { $apiResponse = Invoke-TssApi @invokeParams $restResponse = . $ProcessResponse $apiResponse } catch { Write-Warning 'Issue with Get-TssDiscoveryAccountRuleMatch request' $err = $_ . $ErrorHandling $err } if ($restResponse.records) { [Thycotic.PowerShell.Discovery.AccountRuleMatch[]](. $FilterTssResponse $restResponse.records ([Thycotic.PowerShell.Discovery.AccountRuleMatch])) } } } else { Write-Warning 'No valid session found' } } } |