Public/Read-TppLog.ps1
<#
.SYNOPSIS Read entries from the TPP log .DESCRIPTION Read entries from the TPP log .PARAMETER InputObject TppObject which represents a unique object to search for related records .PARAMETER Path Path to search for related records .PARAMETER Severity Filter records by severity .PARAMETER StartTime Start time of events .PARAMETER EndTime End time of events .PARAMETER Text1 Filter matching results of Text1 .PARAMETER Text2 Filter matching results of Text2 .PARAMETER Value1 Filter matching results of Value1 .PARAMETER Value2 Filter matching results of Value2 .PARAMETER Limit Specify the number of items to retrieve, starting with most recent. The default is 100 and there is no maximum. .PARAMETER VenafiSession Session object created from New-VenafiSession method. The value defaults to the script session object $VenafiSession. .INPUTS InputObject .OUTPUTS PSCustomObject with properties: ClientTimestamp Component ComponentId ComponentSubsystem Data Grouping Id Name ServerTimestamp Severity SourceIP Text1 Text2 Value1 Value2 .EXAMPLE Read-TppLog -Limit 10 Get the most recent 10 log items .EXAMPLE $capiObject | Read-TppLog Find all events for a specific object .LINK http://VenafiPS.readthedocs.io/en/latest/functions/Read-TppLog/ .LINK https://github.com/gdbarron/VenafiPS/blob/main/VenafiPS/Code/Public/Read-TppLog.ps1 .LINK https://docs.venafi.com/Docs/20.4SDK/TopNav/Content/SDK/WebSDK/r-SDK-GET-Log.php?tocpath=Web%20SDK%7CLog%20programming%20interface%7C_____2 #> function Read-TppLog { [CmdletBinding(DefaultParameterSetName = 'Default')] param ( [Parameter(Mandatory, ValueFromPipeline, ParameterSetName = 'ByObject')] [TppObject] $InputObject, [Parameter(Mandatory, ParameterSetName = 'ByPath')] [ValidateScript( { if ( $_ | Test-TppDnPath ) { $true } else { throw "'$_' is not a valid DN path" } })] [Alias('DN')] [string] $Path, [Parameter()] [TppEventSeverity] $Severity, [Parameter()] [DateTime] $StartTime, [Parameter()] [DateTime] $EndTime, [Parameter()] [ValidateNotNullOrEmpty()] [string] $Text1, [Parameter()] [ValidateNotNullOrEmpty()] [string] $Text2, [Parameter()] [int] $Value1, [Parameter()] [int] $Value2, [Parameter()] [Int] $Limit, [Parameter()] [VenafiSession] $VenafiSession = $script:VenafiSession ) begin { $VenafiSession.Validate() | Out-Null $params = @{ VenafiSession = $VenafiSession Method = 'Get' UriLeaf = 'Log/' Body = @{ } } switch ($PSBoundParameters.Keys) { 'Severity' { $params.Body.Add('Severity', $Severity) } 'StartTime' { $params.Body.Add('FromTime', ($StartTime | ConvertTo-UtcIso8601) ) } 'EndTime' { $params.Body.Add('ToTime', ($EndTime | ConvertTo-UtcIso8601) ) } 'Text1' { $params.Body.Add('Text1', $Text1) } 'Text2' { $params.Body.Add('Text2', $Text2) } 'Value1' { $params.Body.Add('Value1', $Value1) } 'Value2' { $params.Body.Add('Value2', $Value2) } 'Limit' { $params.Body.Add('Limit', $Limit) } } } process { switch ($PSCmdlet.ParameterSetName) { 'ByObject' { $params.Body.Component = $InputObject.Path } 'ByPath' { $params.Body.Component = $Path } } Invoke-TppRestMethod @params | Select-Object -ExpandProperty LogEvents } } |