Created
March 29, 2018 22:47
-
-
Save tostka/6617d5c322881443a5ca8ded7261d24b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 ; | |
} ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gist up 2013-vintage code from old blog posts