Extracting Webdrawer User Queries

Content Manager does now capture user queries into the workgroup server logs, but it doesn't give you any information about Webdrawer.  Luckily IIS comes to the rescue via the site logs automatically enabled on the server.  Every time a user requests a resource from the IIS site, an entry is added to the daily log file contained inside W3SVC directory in the "c:\inetpub\logs\LogFiles" folder (or wherever your techie has redirected those logs to).

These logs can be parsed by a host of applications.  A quick google search yields a treasure trove of free applications that can analyze these logs and expose important information.  What they lack though is the unique signature of record queries.  

We can use Powershell to target just the record queries though!


After running the Powershell script, I can see that there have been 51 searches for "All" records and 17 searches for "Registered On=This Year".  Right now this PowerShell script is simply writing to my screen, but in a later post we'll do much much more!  For instance, I'll write the results to a file within my Webdrawer instance.... so that the main landing page provides a direct link to the top 5 searches people perform (obviating the need for users to always use the awkward search interface).

My PowerShell script is as follows:

$queries = [ordered]@{}
$sourceDir = 'C:\inetpub\logs\LogFiles\W3SVC1'
$logs = Get-ChildItem $sourceDir -Filter *.log
foreach ( $log in $logs ) 
    $content = get-content "$($sourceDir)\$($log)" |%{$_ -replace '#Fields: ', ''} |?{$_ -notmatch '^#'} | ConvertFrom-Csv -Delimiter ' '
    foreach ( $entry in $content ) 
        if ( $entry.'cs-uri-stem' -like '*/Record' ) 
            if ( $queries.Contains($entry.'cs-uri-query') ) 
            } else {
$queries | Format-Table