Relevance to determine if the default documents are enabled in IIS

I need to find all the web servers in my environment that have the default documents enabled. I am looking for the existence of the “web.config” file in this folder “C:\inetpub\wwwroot” and contains the line defaultDocument enabled=“true”.

below is the content of the file.

<?xml version="1.0" encoding="UTF-8"?>
            <remove fileExtension=".mp4" />
            <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
            <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" />
                    <add verb="TRACE" allowed="false" />
                    <add verb="TRACK" allowed="false" />
        <defaultDocument enabled="false">
                <clear />
                <add value="iisstart.htm" />
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="index.htm" />
                <add value="index.html" />
                <add value="default.aspx" />

This is the query that I am trying but it is not working. I get error “The operator “true” is not defined.”

exist file “C:\inetpub\wwwroot\web.config” whose (exists (line of it) whose (it contains “defaultDocument enabled=“true””))

I think I need to use xpaths to get the desired results but I haven’t been able to get the working either. Any help with this would be greatly appreciated.


First, Thank you so much for using the code tag, and for providing the exact file as well as providing your “relevance so far” These are all hugely helpful to those who want to help you.

tweaking your relevance just a bit, you might consider this:

q: exists lines whose (it contains "defaultDocument" and it contains "enabled" and it contains "true") of file "C:\inetpub\wwwroot\web.config"

Now, that will probably work for you, but has some issues around case sensitivity, so you might consider

q: exists lines whose (it as lowercase contains "defaultdocument" and it as lowercase contains "enabled" and it as lowercase contains "true") of file "C:\inetpub\wwwroot\web.config" 
A: False

By the way, you were getting True not defined because you had some double quotes in your test string that was breaking your string encapsulation. you can solve that my using %22 for embedded doublequotes

q: exist file "C:\inetpub\wwwroot\web.config" whose (exists (line whose (it contains "defaultDocument enabled=%22true%22") of it) )
A: False

And since you mentioned XPATH… that is even better.

q: node value of xpath "/configuration/system.webServer/defaultDocument/@enabled" of xml document of file "C:\inetpub\wwwroot\web.config"
A: false

q: exists file "C:\inetpub\wwwroot\web.config" whose (node value of xpath "/configuration/system.webServer/defaultDocument/@enabled" of xml document of it as lowercase = "false" )
A: True
T: 0.735 ms
I: singular Boolean

And your final relevance:

q: exists file "C:\inetpub\wwwroot\web.config" whose (node value of xpath "/configuration/system.webServer/defaultDocument/@enabled" of xml document of it as lowercase = "true" )
A: False
T: 1.430 ms
I: singular boolean