« Apache Configuration and PCI Compliance - Configuration Change #3 | Main | Tomcat - Disable TRACE Method »


Updated Powershell Script to Test For Trace

This article has been superseded by this one. 
No further updates will be made to this article.

In a previous post, I posted a basic powershell script that would test a site to see whether the TRACE method was enabled or not. I've updated that script so now you can test for other methods. Here is the updated script:

## USAGE: ./testURL.ps1 <http-method-to-test> <site-to-test-without-trailing-slash>
## Not sure why, but this script returns true if you use a URL like http://www.apache.org
## but fails if you use the correct URI syntax (http://www.apache.org/ << note trailing slash

param ($method,$url)

Write-Host $_
#clean up the current request
#an error occurred. ignore it and continue to returning false.

$request = [System.Net.WebRequest]::Create($url)
$request.Method = $method
$request.TimeOut = 5000
if ($request.GetResponse().StatusCode -eq "OK")
#clean up the current request
return $true
#should get here only if we got an error for our web request
return $false

Running the script is a matter of typing in the method you want to execute followed by the URL of the site you want to test: ".\testURLv2.ps1 %HTTPMETHOD% %URL%"

Enjoy! This script allows you to test to see if Methods like TRACK and OPTIONS work in additon to simply testing that the TRACE method works.


TrackBack URL for this entry:

Listed below are links to weblogs that reference Updated Powershell Script to Test For Trace: