functions/discovery/Get-TssDiscoverySourceAudit.ps1
|
function Get-TssDiscoverySourceAudit { <# .SYNOPSIS Get discovery source audit records .DESCRIPTION Lists the audit records of discovery sources (create, update, enable, disable), newest first. Use -DiscoverySourceId to list the records of one source. .PARAMETER TssSession TssSession object created by New-TssSession for authentication .PARAMETER DiscoverySourceId Only return the audit records of this discovery source .EXAMPLE $session = New-TssSession -SecretServer https://alpha -Credential $ssCred Get-TssDiscoverySourceAudit -TssSession $session List the audit records of all discovery sources .EXAMPLE $session = New-TssSession -SecretServer https://alpha -Credential $ssCred Get-TssDiscoverySourceAudit -TssSession $session -DiscoverySourceId 3 List the audit records of discovery source 3 .LINK https://thycotic-ps.github.io/thycotic.secretserver/commands/discovery/Get-TssDiscoverySourceAudit .LINK https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/discovery/Get-TssDiscoverySourceAudit.ps1 .NOTES Requires TssSession object returned by New-TssSession #> [CmdletBinding()] [OutputType('Thycotic.PowerShell.Discovery.SourceAudit[]')] param ( [Parameter(Mandatory, ValueFromPipeline, Position = 0)] [Thycotic.PowerShell.Authentication.Session] $TssSession, [int] $DiscoverySourceId ) 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 $uri = $TssSession.ApiUrl, 'discovery-source', 'audit' -join '/' $queryParams = @() $queryParams += "take=$($TssSession.Take)" switch ($tssParams.Keys) { 'DiscoverySourceId' { $queryParams += "filter.discoverySourceId=$($DiscoverySourceId)" } } 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-TssDiscoverySourceAudit request' $err = $_ . $ErrorHandling $err } if ($restResponse.records) { [Thycotic.PowerShell.Discovery.SourceAudit[]](. $FilterTssResponse $restResponse.records ([Thycotic.PowerShell.Discovery.SourceAudit])) } } else { Write-Warning 'No valid session found' } } } |