<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Indented! &#187; IIS</title>
	<atom:link href="http://www.indented.co.uk/index.php/tag/iis/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.indented.co.uk</link>
	<description></description>
	<lastBuildDate>Fri, 02 Jul 2010 10:45:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>PowerShell, IIS and log settings</title>
		<link>http://www.indented.co.uk/index.php/2010/01/12/powershell-iis-and-log-settings/</link>
		<comments>http://www.indented.co.uk/index.php/2010/01/12/powershell-iis-and-log-settings/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 10:06:45 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[IIS]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[wmi]]></category>

		<guid isPermaLink="false">http://www.indented.co.uk/?p=1353</guid>
		<description><![CDATA[A function to retrieve IIS log settings from a local or remote IIS 6 server. Written to be compatible with PowerShell 1.0. Function Get-IISLogSetting { Param([String[]]$Servers = $Env:Computername) $Servers &#124; %{ $Server = $_ $WMI = New-Object Management.ManagementScope(&#34;\\$Server\root\MicrosoftIISv2&#34;) $WMI.Options.Authentication = &#34;PacketPrivacy&#34; $Query = New-Object Management.ObjectQuery( ` &#34;SELECT Name, LogFileDirectory, LogFileTruncateSize, &#34; + ` &#34;LogType, LogFilePeriod [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>A function to retrieve IIS log settings from a local or remote IIS 6 server. Written to be compatible with PowerShell 1.0.<br />
<span id="more-1353"></span></p>
<pre class="brush: powershell;">
Function Get-IISLogSetting
{
  Param([String[]]$Servers = $Env:Computername)

  $Servers | %{
    $Server = $_

    $WMI = New-Object Management.ManagementScope(&quot;\\$Server\root\MicrosoftIISv2&quot;)
    $WMI.Options.Authentication = &quot;PacketPrivacy&quot;
    $Query = New-Object Management.ObjectQuery( `
      &quot;SELECT Name, LogFileDirectory, LogFileTruncateSize, &quot; + `
      &quot;LogType, LogFilePeriod FROM IIsWebServerSetting&quot;)

    $Searcher = New-Object Management.ManagementObjectSearcher($WMI, $Query)

    Trap [UnauthorizedAccessException]
    {
      Write-Error &quot;$($Server): Unable to connect or Access is denied&quot;
      continue
    }
    $Searcher.Get() | Select-Object `
      @{n='Name';e={ $Server }}, `
      @{n='Site';e={ $_.Name }}, `
      @{n='IIS Logging';e={
        Switch ($_.LogType) {
          0 { &quot;Disabled&quot; }
          1 { &quot;Enabled&quot; }
        } }}, `
      @{n='Log Path';e={ $_.LogFileDirectory }}, `
      @{n='Log File Size';e={
        If ([Int]$_.LogFileTruncateSize -eq -1) { &quot;Unlimited&quot; } else {
          &quot;$([Int]$_.LogFileTruncateSize / 1Gb) Gb&quot; } }}, `
      @{n='Log File Rollover';e={
        Switch ($_.LogFilePeriod) {
          0 { &quot;Size&quot; }
          1 { &quot;Date&quot; }
        } }}
  }
}
</pre>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.indented.co.uk/index.php/2010/01/12/powershell-iis-and-log-settings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Log file scrubber for IIS</title>
		<link>http://www.indented.co.uk/index.php/2008/10/22/iis-log-file-scrubber/</link>
		<comments>http://www.indented.co.uk/index.php/2008/10/22/iis-log-file-scrubber/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 14:29:38 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[IIS]]></category>
		<category><![CDATA[VbScript]]></category>
		<category><![CDATA[log files]]></category>
		<category><![CDATA[vbs]]></category>

		<guid isPermaLink="false">http://www.highorbit.co.uk/?p=407</guid>
		<description><![CDATA[I wrote this script quite a few years ago to reduce the size of IIS log files by removing log entries for trivial requests (based on file extension for the request). The version below only removes successful log entries for any request for gif and jpg images. However, as they tend to make up a [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I wrote this script quite a few years ago to reduce the size of IIS log files by removing log entries for trivial requests (based on file extension for the request).<br />
<span id="more-407"></span><br />
The version below only removes successful log entries for any request for gif and jpg images. However, as they tend to make up a large portion of the log this can significantly reduce the size of the file, an improvement for long(er) term storage on busy servers.</p>
<p>It has a couple of short-comings. Error control is minimal, and reporting is non-existent.</p>
<pre class="brush: vb;">
' ScrubLogs.vbs
'
' Author: Chris Dent
' Date: 18/05/2005
' Modified: 07/06/2005
'
' Part of Log File Management. Removes successful file requests from targetted
' log files based on the contents of arrFileExtensions.
'
' Cannot be used on todays log file - locked by IIS.

Option Explicit

' The file extensions you want to remove successful requests for

Dim arrFileExtensions
arrFileExtensions = Array(&quot;gif&quot;, &quot;jpg&quot;)

Function GetLogFolders(strServer)
  ' Returns a dictionary with log file path, site ID and
  ' comment for each site

  Dim objIISWeb, objSites, objNode

  On Error Resume Next : Err.Clear
  Set objIISWeb = GetObject(&quot;IIS://&quot; &amp; strServer &amp; &quot;/W3SVC&quot;)
  If Err.Number &lt;&gt; 0 Then
    WScript.Echo &quot;Failed to connect to metabase: &quot; &amp; Err.Description
  End If
  On Error Goto 0

  Set objSites = CreateObject(&quot;Scripting.Dictionary&quot;)

  For Each objNode in objIISWeb
    If LCase(objNode.Class) = &quot;iiswebserver&quot; Then
      objSites.Add objNode.Name, _
        Array(objNode.LogFileDirectory, objNode.ServerComment)
    End If
  Next
  Set objIISWeb = Nothing

  Set GetLogFolders = objSites

  Set objSites = Nothing
End Function

Sub ScrubFolders(objSites)
  ' Loops through objSites, checks the log file folder and checks files

  Dim strSite, strLogFolder
  Dim objFileSystem, objFolder, objFile

  Set objFileSystem = CreateObject(&quot;Scripting.FileSystemObject&quot;)

  For Each strSite in objSites
    strLogFolder = objSites(strSite)(0) &amp; &quot;\W3SVC&quot; &amp; strSite
    If objFileSystem.FolderExists(strLogFolder) Then

      Set objFolder = objFileSystem.GetFolder(strLogFolder)
      For Each objFile in objFolder.Files

        ' Skip files last modified within the last 24 hours
        If objFile.DateLastModified &lt; (Now - 1) Then
          ScrubLog objFile
        End If
      Next

    End If
  Next

  Set objFileSystem = Nothing
End Sub

Sub ScrubLog(objFile)
  Dim strTempFile, strLine, strLogName, strElement, strExtension
  Dim arrLine
  Dim objFileSystem, objTempFile, objStream
  Dim booFields, booIgnore, booRemoveExt
  Dim intFieldCount, intFileName, intStatus, int40x, int50x

  strTempFile = objFile.Path &amp; &quot;.temp&quot;
  Set objFileSystem = CreateObject(&quot;Scripting.FileSystemObject&quot;)
  Set objTempFile = objFileSystem.CreateTextFile(strTempFile, True, False)

  booFields = False

  ' Process everything in the Log File

  Set objStream = objFile.OpenAsTextStream(1,0)
  Do While Not objStream.AtEndOfStream
    booIgnore = False
    strLine = objStream.ReadLine()
    arrLine = split(strLine, &quot; &quot;)

    ' Get the field positions

    If (arrLine(0) = &quot;#Fields:&quot;) Then
      intFieldCount = 0

      For Each strElement in arrLine
        If strElement = &quot;cs-uri-stem&quot; Then
          intFileName = intFieldCount - 1
        ElseIf strElement = &quot;sc-status&quot; Then
          intStatus = intFieldCount - 1
        End If
        intFieldCount = intFieldCount + 1
      Next
      booFields = True
    End If

    ' Just rewrite any line beginning with #

    If (Left(arrLine(0), 1) = &quot;#&quot;) Then
      objTempFile.WriteLine strLine
      booIgnore = True
    End If

    If booFields = True And booIgnore = False Then

      ' A quick check to see if the cs-uri-stem field has one
      ' of the extensions we're interested in

      booRemoveExt = False
      For Each strExtension in arrFileExtensions
        If InStr(1, Right(arrLine(intFileName), 3), strExtension, 1) &lt;&gt; 0 Then
          booRemoveExt = True
        End If
      Next

      ' Write the line back to the new log unless it's a successful request
      ' for the file extensions we're removing

      If booRemoveExt = True Then
        int40x = InStr(1, Left(arrLine(intStatus), 2), &quot;40&quot;, 1)
        int50x = InStr(1, Left(arrLine(intStatus), 2), &quot;50&quot;, 1)
        If (int40x &lt;&gt; 0) or (int50x &lt;&gt; 0) Then
          objTempFile.WriteLine strLine
        End If
      Else
        objTempFile.WriteLine strLine
      End If
    End If
  Loop

  ' Delete the original log file

  Set objStream = Nothing
  strLogName = objFile.Name
  objFile.Delete
  Set objFile = Nothing

  ' Rename the temp file to match the original

  Set objTempFile = Nothing
  Set objTempFile = objFileSystem.GetFile(strTempFile)
  objTempFile.Name = strLogName
  Set objTempFile = Nothing
  Set objFileSystem = Nothing
End Sub

'
' Main Code
'

Dim objLogFolders
Set objLogFolders = GetLogFolders(&quot;localhost&quot;)
ScrubFolders objLogFolders
Set objLogFolders = Nothing
</pre>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.indented.co.uk/index.php/2008/10/22/iis-log-file-scrubber/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
