Script Tips

Knock, Knock, But No One's Home

Quick way to check out why a Web page isn't responsive.

One thing administrators often have to worry about is bad links on a Web page, or even a Web server that isn’t responding. VBScript can give you a quick solution for checking a particular Web page (and thus the server), by using the Microsoft XMLHTTP object.

Using it is simple:

sTestURL = "http://www.scriptinganswers.com"
Set oHTTP = CreateObject("MSXML2.XMLHTTP")
Call oHTTP.Open("GET", sTestURL, False)
oHTTP.Send
If oHTTP.Status <> 202
  WScript.Echo "Couldn’t reach URL; error: " & oHTTP.Status
Else
  WScript.Echo "URL pinged successfully"
End If

You can also access oHTTP.ResponseText to get the contents of the Web page you retrieved. This is a fast and easy way to quickly check a Web page or even an entire Web server. (If the server can’t return a page that is known to exist, such as index.htm, then the server itself may be down.) You could extend the script to quickly check several servers at once, giving you a snapshot status of an entire Web farm.

Using oHTTP.ResponseText allows you to check the actual contents of the Web page you retrieved. You could then use string-handling functions to check the Web page for specific content (such as using InStr() to see if the page contained a particular word). The XMLHTTP object is just one of many COM objects built into Windows that VBScript can leverage to perform useful administrative tricks.

About the Author

Don Jones is a multiple-year recipient of Microsoft’s MVP Award, and is Curriculum Director for IT Pro Content for video training company Pluralsight. Don is also a co-founder and President of PowerShell.org, a community dedicated to Microsoft’s Windows PowerShell technology. Don has more than two decades of experience in the IT industry, and specializes in the Microsoft business technology platform. He’s the author of more than 50 technology books, an accomplished IT journalist, and a sought-after speaker and instructor at conferences worldwide. Reach Don on Twitter at @concentratedDon, or on Facebook at Facebook.com/ConcentratedDon.

Featured

  • Windows Has Support for Encrypted DNS

    Microsoft announced this week that the Windows operating system already has support for an encrypted Domain Name System option that promises to add greater privacy protections for Internet connections.

  • The Datacenter in 2020 and Beyond: More Edge, 'As-a-Service' and AI

    The next few years are going to be lively ones for the datacenter, according to research firm IDC's "Futurescape" report.

  • Inking Gains Traction in Office 365

    From PowerPoint to Excel, Microsoft is beefing up its support for digital inking across its Office 365 apps. Here's a snapshot of upcoming features.

  • Salesforce and Microsoft Partnering on Azure Services and Teams

    Salesforce.com and Microsoft on Thursday announced a strategic partnership on cloud technology use.

comments powered by Disqus

Office 365 Watch

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.