2

I have a IIS6 web server with 100+ sites on it. Recently, I was forced to renew my wildcard SSL certificate which all the sites use by creating a new CSR request rather than a renew CSR request. I have installed the certificate and can update each site one at a time to use the new certificate however, I was wondering whether:

  1. There is a way to update every site at the same time and
  2. If there was a script I can use to view which certificate is currently being used by each site.

1 Answer 1

1

I have an answer for the second item for those that are interested. Create a text file with the contents below and save it with a .vbs extention. Then execute it with cscript myfile.vbs from the command-line. If you execute it as cscript myfile.vbs > output.txt it will put the results in a text file.

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  

I pulled this script from here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.