Option Explicit
REM This script uses ADSI to search for all machines running IIS in your domain
REM
REM Written by Greg Thatcher, http://www.GregThatcher.com
REM Motivated by "Professional ADSI Programming" by Simon Robinson, Wrox Press
REM
REM Copy this script to your Windows 2000 machine, save it as iisscan.vbs
REM From a command prompt, type cscript iisscan.vbs domainname
REM where 'domainname' is the domain you wish to scan for IIS installations
Function ComputerHasIIS (domainName, computerName)
Dim station
Dim path
ComputerHasIIS = false
path = "WinNT://" & domainName & "/" & computerName & "/W3SVC"
On Error Resume Next
'WScript.Echo (path)
Set station = GetObject(path)
If (Err.number = 0) Then
Dim status
status = 0 + station.status
'WScript.Echo status
'If ((status & 7) = 4) Then
If (status >= 4) Then
WScript.Echo domainName & "/" & computerName & " has IIS installed."
End If
End If
End Function
Function ShowDomainNames
Dim domains
Dim foundDomain
On Error Resume Next
Set domains = GetObject("WinNT:")
If (Err.number = 0) Then
domains.Filter = Array("Domain")
foundDomain = false
For Each foundDomain in domains
If (foundMachine = false) Then
WScript.Echo vbCRLF & "The following domains were found on this machine (your account may not have priviledges to see all domains):"
End If
WScript.Echo foundDomain.Name
foundMachine = true
Next
End If
End Function
Dim domainName
Dim computer
Dim domain
Dim foundMachine
Dim objArgs
Set objArgs = WScript.Arguments
If (objArgs.Count < 1) Then
WScript.Echo "Usage: iisscan.vbs "
WScript.Echo "Usage: cscript iisscan.vbs "
ShowDomainNames
WScript.Quit
End If
domainName = objArgs(0)
'On Error Resume Next
Set domain = GetObject("WinNT://" & domainName)
If Not (Err.number = 0) Then
WScript.Echo "Couldn't get domain information for '" & domainName & "'. Make sure that domain name is valid, and that you have Administrative rights for this domain."
ShowDomainNames
WScript.Quit
End If
domain.Filter = Array("Computer")
foundMachine = false
For Each Computer in domain
Dim computerName
computerName = Computer.Name
REM WScript.Echo "Checking " & computerName
If (ComputerHasIIS (domainName, computerName)) Then
WScript.Echo computerName & " has IIS installed."
End If
foundMachine = true
Next
If (foundMachine = false) Then
WScript.Echo "Couldn't find any machines in '" & domainName & "'. Make sure that domain name is valid, and that you have Administrative rights for this domain."
ShowDomainNames
WScript.Quit
End If
WScript.Echo "Programming by Greg Thatcher, MCSD, MCAD, MCDBA, MCSE"
|