Dim W3SVC,WebServer,Bindings,ALLBindingInfo,fs,TextFilePath,WebSiteName
On Error Resume Next
Err.Clear
Set fs = WScript.CreateObject("Scripting.FileSystemObject")
TextFilePath = fs.GetFile(WScript.ScriptFullName).ParentFolder.Path & "IISBindingCheck.tmp"
AllBindingInfo = ""
Computer = "localhost"
Set W3SVC = GetObject("IIS://" & Computer & "/W3SVC")
For Each WebServer in W3SVC
If IsNumeric(WebServer.Name) Then
WebSiteName = WebServer.ServerComment
Bindings = WebServer.ServerBindings
For i = LBound(Bindings) To UBound(Bindings)
BindingInfo = Bindings(i)
nStart = InStr(BindingInfo,":")
IP = Mid(BindingInfo,1,nStart - 1)
nEnd = InStr(nStart + 1,BindingInfo, ":")
Port = Mid(BindingInfo,nStart + 1 ,nEnd - nStart -1)
ALLBindingInfo = ALLBindingInfo & IP & ":" & Port & ":" & WebSiteName & vbCrlf
Next
End If
Next
ALLBindingInfo = Left(AllBindingInfo,Len(ALLBindingInfo) - 2)
fs.CreateTextFile(TextFilePath).Write ALLBindingInfo