Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tostka/6617d5c322881443a5ca8ded7261d24b to your computer and use it in GitHub Desktop.
Save tostka/6617d5c322881443a5ca8ded7261d24b to your computer and use it in GitHub Desktop.
# Array of IIS paths, stored as semi-colon-delimited string
$LogDirs="\\US-HUBCAS1\e$\Weblogs\W3SVC1\;\\US-HUBCAS2\e$\Weblogs\W3SVC1\" ; $LogDirs=$LogDirs.split(";") ;
# constants for single & double quotes
$sQuot = [char]34 ; $sQuotS = [char]39 ;
foreach ($LogDir in $LogDirs) {
# build the log path to today's logs
$sTodaysLogsStr = $LogDir ;
# Ex2007 IIS log filename variant
#$sTodaysLogsStr += "ex" ;
# Ex2010 variant
$sTodaysLogsStr += "u_ex" ;
$sTodaysLogsStr += (Get-Date -format "yMMdd") + "*.log" ;
# build the logparser sql command
$strSQL = "SELECT QUANTIZE(TO_LOCALTIME(time),3600) AS Hour, count(*) AS Hits" ;
$strSQL += " FROM " + ($sQuotS + $sTodaysLogsStr + $sQuotS) ;
$strSQL += " WHERE cs-uri-stem LIKE '%/EWS/%' GROUP BY Hour ORDER BY Hour" ;
# assemble the logparser commandline
$strExecCmd = ". logparser.exe " + $sQuot + $strSQL + $sQuot + " -rtp:-1" ;
$strExecCmd ;
# execute the assembled command
Invoke-Expression $strExecCmd ;
} ;
@tostka
Copy link
Author

tostka commented Mar 29, 2018

gist up 2013-vintage code from old blog posts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment