none
vbscript - Output to file RRS feed

  • Question

  • Sorry I'm new to VB.  I have some code that pulls SSL certificate from workstations and displays the information on screen.  I would like this information to be outputted to a text file or (.txt, .csv, .xls).

    Also i want to fetch the same output remotely for other machine

    How would I do this?

    Here is my code

    **************

    strComputer = "localhost"  
    Set objService = GetObject( "IIS://" & strComputer & "/W3SVC")  
     
     
    EnumServersites objService   
     
    Public Sub EnumServersites( objSrv )   
        For Each objServer IN objSrv   
            If objServer.Class = "IIsWebServer" Then  
                If Not Ubound(objServer.SecureBindings) = "-1" Then 'check to see if there is at least one securebinding   
                    WScript.Echo "Site ID = " & objServer.Name & VbCrLf & "Comment = """ & objServer.ServerComment   
                    wscript.Echo "SSL Certificate Expiration Date: " & GetSSLExpirationDate(objServer.Name)   
                    wscript.Echo "Days Remaining: " & DaysRemaining(GetSSLExpirationDate(objServer.Name))   
                    wscript.echo vbcrlf & "-----------------------------" & vbcrlf  
                     
                     
          End If  
        
        End If
     
        strBindings = vbNullString
    Next  
       
    End Sub  
     
    Private Function GetSSLExpirationDate( strSiteID )   
        Set iiscertobj = WScript.CreateObject("IIS.CertObj")   
        iiscertobj.serverName = "localhost"  
        iiscertobj.InstanceName = "W3SVC/" & strSiteID   
     
        tmpArray = Split(iiscertobj.GetCertInfo,vbLf)   
        For Each x in tmpArray   
            If Left(x,2) = "6=" Then  
                GetSSLExpirationDate = Mid(x,3,len(x)-2)   
            End If  
        Next  
    End Function
     
    Private Function DaysRemaining(strdate)   
        If IsDate(strDate) Then  
            strdate = cDate(strdate)   
        End If  
        DaysRemaining = DateDiff("d",Date,strdate)  
     
     
                     
    End Function 

    • Moved by Bill_Stewart Tuesday, November 7, 2017 10:04 PM This is not "fix/debug/rewrite this script I found on the Internet" forum
    Friday, September 22, 2017 8:42 PM

All replies