<p>If you have used IIS for any length of time you have probably come across the term FREB. If you don't know what it is then you should read this great introduction to <a href="http://learn.iis.net/page.aspx/266/troubleshooting-failed-requests-using-tracing-in-iis-7/">Failed Request Tracing in IIS</a>. It's applicable to IIS7 and above and is a great tool.</p>

At a high level FREB produces an XML file containing details of errors you are interested in - you specify the error code you want to trap, the execution time threshold or a number of other filters - and provides a wealth of information about what was happening under the covers in IIS.

The problem with FREB Tracing though is that it's very easy to end up with a folder containing hundreds or even thousands of error reports - all named a variant on fr000123.xml - and you have no way to quickly tell which where the ones with details of 401.3 errors, or which ones failbed because they took more than 5 seconds to execute.

Well, thanks to the wonders of powershell there's now a simple solution.

Frebber scans the output directory where your FREB logs are stored and copies the files into a new subdirectory (called .Frebber of course) while at the same time renaming the files based on the nature of the error report they contain.

For instance fr000012.xml may contain details of an HTTP 415 error and took 2571ms to execute, so the file would be renamed 415_STATUS_CODE_2571_fr000012.xml

It's a fairly simple script and if you have a look at the XML format inside a FREB report you'll be able to see how to adapt it quickly to your particular needed. Meanwhile feel free to use the example below, and I'd love to hear any comments or suggestions in the comments.

Oh, it does make one pretty big assumption... that your FREB files are going to the default directory. If that's not that case then you will need to modify that line (I might get around to making the script more complete and add parameter for source and destination directories and some renaming selection criteria but right now this works pretty well for me

$frebDir = "c:inetpublogsFailedReqLogFilesW3SVC1"
echo "Frebbering...."
$fileEntries = Get-ChildItem $frebdir*.* -include *.xml;
$outDir = $frebDir + ".Frebber"
# Create the directory for the Frebberized files
$temp = New-Item $outDir -type directory -force
# copy in the freb.xsl so you can still view them
Copy-Item ($frebDir+"freb.xsl") $outDir
$numFrebbered = 0
foreach($fileName in $fileEntries) 
{
    [System.Xml.XmlDocument] $xd = new-object System.Xml.XmlDocument
    $frebFile = $frebDir + $fileName.name;
    $xd.load($frebFile)
    $nodelist = $xd.selectnodes("/failedRequest")
    foreach ($testCaseNode in $nodelist) 
    {
        $url = $testCaseNode.getAttribute("url")
        $statusCode = $testCaseNode.getAttribute("statusCode")
        $failureReason = $testCaseNode.getAttribute("failureReason")
        $timeTaken =  $testCaseNode.getAttribute("timeTaken")
        $outFile = $frebDir + ".Frebber" + $statusCode + "_" + $failureReason + "_" + $timeTaken + "_" + $fileName.name;
        Copy-Item $frebFile $outFile
        $numFrebbered +=1
    }
}         
echo "Frebbered $numFrebbered files to $outdir."