This script takes the outboxlog.txt file from the Windows Server fax service and parses it to find faxes that did not complete. Results are dumped as a Web page. Normally a user can view only the status of their own faxes. This allows you to view failed faxes for any user.

This script can be run as a scheduled task to provide a constantly updated list. Required command line in scheduled task is: powershell.exe "& 'C:\ProgramData\Microsoft\Windows NT\MSFax\ActivityLog\ParseOutbox.ps1'"

PowerShell
Edit|Remove
# This script takes the outboxlog.txt file from the Windows Server fax service
# and parses it to find faxes that did not complete. Results are dumped as a
# Web page. Normally a user can view only the status of their own faxes.
# This allows you to view failed faxes for any user.

# This script can be run as a scheduled task to provide a constantly updated list
# Required command line in scheduled task is:
# powershell.exe "& 'C:\ProgramData\Microsoft\Windows NT\MSFax\ActivityLog\ParseOutbox.ps1'"

# Created by Byron Wright, byron@conexion.ca

# Define the file locations used.
$Source="C:\ProgramData\Microsoft\Windows NT\MSFax\ActivityLog\outboxLog.txt"
$TempSource="C:\ProgramData\Microsoft\Windows NT\MSFax\ActivityLog\outboxlogtemp.txt"
$CsvDestination="C:\ProgramData\Microsoft\Windows NT\MSFax\ActivityLog\outboxlog.csv"
$HTMLDestination="C:\inetpub\wwwroot\FailedFaxes.htm"

# Import-TabDelimited function taken from The PowerShell Guy
# Source located at http://thepowershellguy.com/blogs/posh/archive/2007/03/31/powershell-examples-used-on-ars-technica.aspx

function Import-TabDelimited ($Path) {
  gc $path |% {$header = $true}  {
    if ($header){
      $h = $_.split("`t")
      $header = $false
    }
    Else {
      $r = new-object object
      $_.split("`t") |% {$i=0}{
        $r | add-Member -memberType noteProperty -name $h[$i] -value $_
        $i++
      }
      $r 
    }
  }
}


#Processing the text file may lock it and cause problems on a busy fax server
#So, copy it quick. 
Copy-Item -Path $Source -Destination $TempSource 

#Convert to Outboxlog.txt to a csv file
Import-TabDelimited -Path $TempSource | Export-csv -Path $CsvDestination -NoTypeInformation

#Get a list of faxes that failed by looking at the Status column
#Note that the column name includes double quote. Single quotes used to allow that.
$BadFaxes=import-csv -Path $CsvDestination | where {$_.'"Status"' -eq '"Transmission Error"'}

#Define Web page name
$Header="<H1>Failed Faxes</H1>"

#Dump bad faxes to an HTML file. The Select-Object cmdlet is selecting the columns to include.
#Again note that double quotes are part of the column name.
$BadFaxes | Select-Object '"SubmissionTime"','"RecipientName"','"RecipientFaxNumber"','"CoverPageSubject"','"Document"','"ErrorDesc"' | ConvertTo-HTML -Body $Header | Out-File -FilePath $HTMLDestination