/ Published in: Visual Basic
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
resultPath = "c:\Scripts\Resultados\Websites.txt" set shell = WScript.CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") strServer = shell.ExpandEnvironmentStrings("%ComputerName%") strServerType = "Web" strServerMetaType = "W3SVC" Set destFile = fso.CreateTextFile(resultPath, True) SET objService = GetObject( "IIS://" & strServer & "/" & strServerMetaType ) FOR EACH objServer IN objService IF objServer.Class = "IIs" & strServerType & "Server" THEN destFile.WriteLine("----------------------------------------" & VbCrLf) destFile.WriteLine _ "Site ID = " & objServer.Name & VbCrLf & _ "Comment = """ & objServer.ServerComment & """ " & VbCrLf & _ "State = " & State2Desc( objServer.ServerState ) & VbCrLf & _ "LogDir = " & objServer.LogFileDirectory & _ "" ' Enumerate the HTTP bindings (ServerBindings) and ' SSL bindings (SecureBindings) for HTTPS only strBindings = EnumBindings( objServer.ServerBindings ) IF strServerType = "Web" THEN strBindings = strBindings & _ EnumBindings( objServer.SecureBindings ) END IF destFile.WriteLine("") IF NOT strBindings = "" THEN destFile.WriteLine VbTab & "IP Address" & VbTab & "Port" & VbTab & "Host" destFile.WriteLine strBindings END IF END IF NEXT destFile.WriteLine("----------------------------------------") destFile.Close shell.Run "notepad " & resultPath FUNCTION EnumBindings( objBindingList ) DIM i, strIP, strPort, strHost DIM reBinding, reMatch, reMatches SET reBinding = NEW RegExp reBinding.Pattern = "([^:]*):([^:]*):(.*)" FOR i = LBOUND( objBindingList ) TO UBOUND( objBindingList ) ' objBindingList( i ) is a string looking like IP:Port:Host SET reMatches = reBinding.Execute( objBindingList( i ) ) FOR EACH reMatch in reMatches strIP = reMatch.SubMatches( 0 ) strPort = reMatch.SubMatches( 1 ) strHost = reMatch.SubMatches( 2 ) ' Do some pretty processing IF strIP = "" THEN strIP = "All Unassigned" IF strHost = "" THEN strHost = "*" IF LEN( strIP ) < 8 THEN strIP = strIP & VbTab EnumBindings = EnumBindings & _ VbTab & _ strIP & VbTab & _ strPort & VbTab & _ strHost & VbTab & _ "" NEXT EnumBindings = EnumBindings & VbCrLf NEXT END FUNCTION FUNCTION State2Desc( nState ) SELECT CASE nState CASE 1 State2Desc = "Starting (MD_SERVER_STATE_STARTING)" CASE 2 State2Desc = "Started (MD_SERVER_STATE_STARTED)" CASE 3 State2Desc = "Stopping (MD_SERVER_STATE_STOPPING)" CASE 4 State2Desc = "Stopped (MD_SERVER_STATE_STOPPED)" CASE 5 State2Desc = "Pausing (MD_SERVER_STATE_PAUSING)" CASE 6 State2Desc = "Paused (MD_SERVER_STATE_PAUSED)" CASE 7 State2Desc = "Continuing (MD_SERVER_STATE_CONTINUING)" CASE ELSE State2Desc = "Unknown state" END SELECT END FUNCTION