Using ishRemote, how can I get the DITA OT log file contents in a Get-IshEvent request?

I wrote this little PowerShell routine to get the log for a specific event. I can get the detail, but I cannot figure out how to get the contents of the DITA-OT log file. Can you help me?

I tried looking at IshEventData for the DITAOTLogFile event but the byte array is 0 in length.

$targetServer = "">www.example.com/.../"

if($ishSession -eq $null) {
$ishSession = New-IshSession -WsBaseUrl $targetServer
}

$requestedMetadata = Set-IshRequestedMetadataField -IshSession $ishSession -Name "EVENTID" -Level "Progress" |
Set-IshRequestedMetadataField -IshSession $ishSession -Name "EVENTTYPE" -Level "Progress" |
Set-IshRequestedMetadataField -IshSession $ishSession -Name "EVENTDATATYPE" -Level "Detail" |
Set-IshRequestedMetadataField -IshSession $ishSession -Name "DETAILID" -Level "Detail"

$metadataFilter = Set-IshMetadataFilterField -IshSession $ishSession -Name "DESCRIPTION" -Level "Progress" -FilterOperator Like -Value "Publish process for GUID-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx=3=HTMLOutput=en-us"

$eventLog = Get-IshEvent -IshSession $ishSession -RequestedMetadata $requestedMetadata -EventTypes "PUBLISH" -MetadataFilter $metadataFilter

$eventLog
emoji
Parents
  • Hi Colin, I wrote the below in my shortened lunch break ;)

    I hope the below gets you started. The one thing to imagine is that events have a hierarchy (like Logical-Version-Language). It goes from Progress, which has multiple Detail levels, and then there are some Detail levels with a DataType, that have a leaf level called Data (the binary thing, file attached). So in the below sample will retrieve the binary attached to DITAOTLogFile (a Detail that typically only exists once in a full Progress).

    $requestedMetadata = Set-IshMetadataField -Level Detail -Name EVENTDATATYPE |
                         Set-IshMetadataField -Level Detail -Name EVENTDATASIZE
    $metadataFilter = Set-IshMetadataFilterField -Level Progress -Name DESCRIPTION -FilterOperator Equal -Value "Publish process for GUID-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx=1=PDF (XPP A4)=en-us" |
                      Set-IshMetadataFilterField -Level Detail -Name EVENTDATATYPE -FilterOperator Equal -Value "DITAOTLogFile"
    $e= Get-IshEvent -ModifiedSince (Get-Date).AddDays(-30) -EventTypes "PUBLISH" -MetadataFilter $metadataFilter -RequestedMetadata $requestedMetadata
    
    # there is however no cmdlet to retrieve the binary Data part directly; you can use the Soap proxies to achieve this
    # preferably chunked retrival if larger than 100000 to avoid memory pressure, to simplify the sample asked for the full eventdatasize in one request
    $etNextEventDetailDataChunkRequest = New-Object -TypeName Trisoft.ISHRemote.EventMonitor25ServiceReference.GetNextEventDetailDataChunkRequest -ArgumentList @($e.DetailRef, '0', $e.eventdatasize_detail_value)
    $byteArray = ($ishSession.EventMonitor25.GetNextEventDetailDataChunk($etNextEventDetailDataChunkRequest)).bytes
    $string = [System.Text.Encoding]::UTF8.GetString($byteArray)

    Best wishes,
    Dave

    emoji
  • Yikes! OK to build that request, I'm learning that I need to do the following (based on GitHub - Sarafian/WcfPS: PowerShell module to work with the Wcf pipeline). Am I correct?

    1. Acquire an importer.
    2. Acquire a service endpoint.
    3. Build internal proxy types.
    4. Build the channel for the WCF endpoint.

    Heavy coding...any chance we can get GetNextEventDetailDataChunk into the next update of ishremote?

    emoji
  • Actually, I see no reason to use that WcfPS project.

    The code I shared is working code. Steps 1/2/3/4 that you mention are all done, including authentication, for you in ISHRemote when you use $ishSession.EventMonitor25 you are actually using an authenticated proxy.

    Your steps are indeed how Windows Communication Foundation (WCF) was envisioned by Microsoft - and did its job fine. Depending on the Tridion Docs version you are on, you will get a slightly simpler experience using REST/OpenAPI. However, there is still a reason that you can study to become a Master in Computer Science :)

    Hope this helps.

    emoji
  • The script works perfectly; thank you! I experienced an error testing (entirely my stupid fault) and went down the rathole of WCF authentication. All is well.

    emoji
Reply Children
No Data